You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2008/04/23 11:23:59 UTC
svn commit: r650804 -
/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/
Author: pamarcelot
Date: Wed Apr 23 02:23:46 2008
New Revision: 650804
URL: http://svn.apache.org/viewvc?rev=650804&view=rev
Log:
Added a new LogConsoleMessage class, which is a ConsoleMessage with already existing message streams for the most common Log4J log levels.
Added:
directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/LogMessageConsole.java
directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PreferenceStoreUtils.java
Modified:
directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/Activator.java
directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ColorsAndFontsPage.java
Modified: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/Activator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/Activator.java?rev=650804&r1=650803&r2=650804&view=diff
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/Activator.java (original)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/Activator.java Wed Apr 23 02:23:46 2008
@@ -40,6 +40,9 @@
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.IVMInstallType;
import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.MessageConsole;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -58,6 +61,7 @@
private static Activator plugin;
private ConsoleDisplayMgr consoleDisplayMgr;
+ private MessageConsole logMessageConsole;
/**
@@ -80,36 +84,36 @@
// Configuring Log4J
PropertyConfigurator.configure( Platform.getBundle( PLUGIN_ID ).getResource( "log4j.properties" ) ); //$NON-NLS-1$
logger.info( "Entering Apache Directory Studio." ); //$NON-NLS-1$
-
- // Testing the Console capabilities
- consoleDisplayMgr = new ConsoleDisplayMgr( "Testing Console..." );
-
- consoleDisplayMgr.println( "MSG_INFORMATION", ConsoleDisplayMgr.MSG_INFORMATION );
- consoleDisplayMgr.println( "MSG_WARNING", ConsoleDisplayMgr.MSG_WARNING );
- consoleDisplayMgr.println( "MSG_ERROR", ConsoleDisplayMgr.MSG_ERROR );
-
- IVMInstallType[] types = JavaRuntime.getVMInstallTypes();
- for ( int i = 0; i < types.length; i++ )
- {
- IVMInstallType type = types[i];
- IVMInstall[] jres = type.getVMInstalls();
- for ( IVMInstall vmInstall : jres )
- {
- consoleDisplayMgr.println( vmInstall.getId(), ConsoleDisplayMgr.MSG_INFORMATION );
- consoleDisplayMgr.println( vmInstall.getName(), ConsoleDisplayMgr.MSG_INFORMATION );
- consoleDisplayMgr
- .println( vmInstall.getInstallLocation().toString(), ConsoleDisplayMgr.MSG_INFORMATION );
- consoleDisplayMgr.println( vmInstall.getVMInstallType().toString(), ConsoleDisplayMgr.MSG_INFORMATION );
- consoleDisplayMgr.println( vmInstall.getVMRunner( ILaunchManager.RUN_MODE ).toString(),
- ConsoleDisplayMgr.MSG_INFORMATION );
- System.out.println( vmInstall.getName() );
- }
- }
-
- System.out.println( "*****************" );
-
+
+ // Testing the Console capabilities
+ consoleDisplayMgr = new ConsoleDisplayMgr( "Testing Console..." );
+
+ consoleDisplayMgr.println( "MSG_INFORMATION", ConsoleDisplayMgr.MSG_INFORMATION );
+ consoleDisplayMgr.println( "MSG_WARNING", ConsoleDisplayMgr.MSG_WARNING );
+ consoleDisplayMgr.println( "MSG_ERROR", ConsoleDisplayMgr.MSG_ERROR );
+
+ IVMInstallType[] types = JavaRuntime.getVMInstallTypes();
+ for ( int i = 0; i < types.length; i++ )
+ {
+ IVMInstallType type = types[i];
+ IVMInstall[] jres = type.getVMInstalls();
+ for ( IVMInstall vmInstall : jres )
+ {
+ consoleDisplayMgr.println( vmInstall.getId(), ConsoleDisplayMgr.MSG_INFORMATION );
+ consoleDisplayMgr.println( vmInstall.getName(), ConsoleDisplayMgr.MSG_INFORMATION );
+ consoleDisplayMgr
+ .println( vmInstall.getInstallLocation().toString(), ConsoleDisplayMgr.MSG_INFORMATION );
+ consoleDisplayMgr.println( vmInstall.getVMInstallType().toString(), ConsoleDisplayMgr.MSG_INFORMATION );
+ consoleDisplayMgr.println( vmInstall.getVMRunner( ILaunchManager.RUN_MODE ).toString(),
+ ConsoleDisplayMgr.MSG_INFORMATION );
+ System.out.println( vmInstall.getName() );
+ }
+ }
+
+ System.out.println( "*****************" );
+
IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
- System.out.println( vmInstall.getId() );
+ System.out.println( vmInstall.getId() );
System.out.println( vmInstall.getName() );
System.out.println( vmInstall.getInstallLocation() );
System.out.println( vmInstall.getVMArguments() );
@@ -157,7 +161,7 @@
.getInstallLocation().toString() );
workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
"org.apache.directory.server.Main" );
-
+
IPath bootstrapPath = new Path( "/Users/pajbam/Desktop/apacheds-main.jar" );
IRuntimeClasspathEntry bootstrapEntry = JavaRuntime.newArchiveRuntimeClasspathEntry( bootstrapPath );
bootstrapEntry.setClasspathProperty( IRuntimeClasspathEntry.USER_CLASSES );
@@ -175,6 +179,19 @@
public ConsoleDisplayMgr getConsoleDisplayMgr()
{
return consoleDisplayMgr;
+ }
+
+
+ public MessageConsole getLogMessageConsole()
+ {
+ if ( logMessageConsole == null )
+ {
+ logMessageConsole = new MessageConsole( "Apache DS", null );
+ ConsolePlugin.getDefault().getConsoleManager().addConsoles( new IConsole[]
+ { logMessageConsole } );
+ }
+
+ return logMessageConsole;
}
Modified: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ColorsAndFontsPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ColorsAndFontsPage.java?rev=650804&r1=650803&r2=650804&view=diff
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ColorsAndFontsPage.java (original)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ColorsAndFontsPage.java Wed Apr 23 02:23:46 2008
@@ -20,10 +20,15 @@
package org.apache.directory.studio.apacheds.experimentations;
+import java.io.IOException;
+
+import javax.security.auth.login.LoginContext;
+
import org.eclipse.jface.preference.ColorSelector;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
@@ -35,6 +40,10 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.console.MessageConsoleStream;
/**
@@ -280,6 +289,36 @@
PreferenceConverter.setValue( getPreferenceStore(), PluginConstants.PREFS_COLORS_AND_FONTS_FATAL_COLOR,
fatalColorButton.getColorValue() );
+ LogMessageConsole logMessageConsole = new LogMessageConsole( "toto" );
+ ConsolePlugin.getDefault().getConsoleManager().addConsoles( new IConsole[]
+ { logMessageConsole } );
+
+ RGB rgbBlue = new RGB( 0, 0, 192 );
+ RGB rgbGreen = new RGB( 63, 127, 95 );
+ RGB rgbOrange = new RGB( 255, 127, 0 );
+ RGB rgbRed = new RGB( 255, 0, 0 );
+ RGB rgbDarkRed = new RGB( 127, 0, 0 );
+
+ MessageConsoleStream messageConsoleStream = logMessageConsole.getDebugConsoleMessageStream();
+ messageConsoleStream
+ .println( "[11:23:01] DEBUG [org.apache.directory.server.core.DefaultDirectoryService] - You didn't change the admin password of directory service instance 'default'. Please update the admin password as soon as possible to prevent a possible security breach." );
+
+ messageConsoleStream = logMessageConsole.getInfoConsoleMessageStream();
+ messageConsoleStream
+ .println( "[11:23:01] INFO [org.apache.directory.server.core.DefaultDirectoryService] - You didn't change the admin password of directory service instance 'default'. Please update the admin password as soon as possible to prevent a possible security breach." );
+
+ messageConsoleStream = logMessageConsole.getWarnConsoleMessageStream();
+ messageConsoleStream
+ .println( "[11:23:01] WARN [org.apache.directory.server.core.DefaultDirectoryService] - You didn't change the admin password of directory service instance 'default'. Please update the admin password as soon as possible to prevent a possible security breach." );
+
+ messageConsoleStream = logMessageConsole.getErrorConsoleMessageStream();
+ messageConsoleStream
+ .println( "[11:23:01] ERROR [org.apache.directory.server.core.DefaultDirectoryService] - You didn't change the admin password of directory service instance 'default'. Please update the admin password as soon as possible to prevent a possible security breach." );
+
+ messageConsoleStream = logMessageConsole.getFatalConsoleMessageStream();
+ messageConsoleStream
+ .println( "[11:23:01] FATAL [org.apache.directory.server.core.DefaultDirectoryService] - You didn't change the admin password of directory service instance 'default'. Please update the admin password as soon as possible to prevent a possible security breach." );
+
return super.performOk();
}
@@ -294,8 +333,8 @@
*/
private void setDebug( FontData[] fontDatas, RGB rgb )
{
- boolean bold = isBold( fontDatas );
- boolean italic = isItalic( fontDatas );
+ boolean bold = PreferenceStoreUtils.isBold( fontDatas );
+ boolean italic = PreferenceStoreUtils.isItalic( fontDatas );
debugColorButton.setColorValue( rgb );
debugBoldCheckbox.setSelection( bold );
debugItalicCheckbox.setSelection( italic );
@@ -312,8 +351,8 @@
*/
private void setInfo( FontData[] fontDatas, RGB rgb )
{
- boolean bold = isBold( fontDatas );
- boolean italic = isItalic( fontDatas );
+ boolean bold = PreferenceStoreUtils.isBold( fontDatas );
+ boolean italic = PreferenceStoreUtils.isItalic( fontDatas );
infoColorButton.setColorValue( rgb );
infoBoldCheckbox.setSelection( bold );
infoItalicCheckbox.setSelection( italic );
@@ -330,8 +369,8 @@
*/
private void setWarn( FontData[] fontDatas, RGB rgb )
{
- boolean bold = isBold( fontDatas );
- boolean italic = isItalic( fontDatas );
+ boolean bold = PreferenceStoreUtils.isBold( fontDatas );
+ boolean italic = PreferenceStoreUtils.isItalic( fontDatas );
warnColorButton.setColorValue( rgb );
warnBoldCheckbox.setSelection( bold );
warnItalicCheckbox.setSelection( italic );
@@ -348,8 +387,8 @@
*/
private void setError( FontData[] fontDatas, RGB rgb )
{
- boolean bold = isBold( fontDatas );
- boolean italic = isItalic( fontDatas );
+ boolean bold = PreferenceStoreUtils.isBold( fontDatas );
+ boolean italic = PreferenceStoreUtils.isItalic( fontDatas );
errorColorButton.setColorValue( rgb );
errorBoldCheckbox.setSelection( bold );
errorItalicCheckbox.setSelection( italic );
@@ -368,59 +407,11 @@
*/
private void setFatal( FontData[] fontDatas, RGB rgb )
{
- boolean bold = isBold( fontDatas );
- boolean italic = isItalic( fontDatas );
+ boolean bold = PreferenceStoreUtils.isBold( fontDatas );
+ boolean italic = PreferenceStoreUtils.isItalic( fontDatas );
fatalColorButton.setColorValue( rgb );
fatalBoldCheckbox.setSelection( bold );
fatalItalicCheckbox.setSelection( italic );
- }
-
-
- /**
- * Indicates if the given array of {@link FontData} is bold.
- *
- * @param fontDatas
- * the array
- * @return
- * <code>true</code> if the given array of {@link FontData} is bold, <code>false</code> if not.
- */
- private boolean isBold( FontData[] fontDatas )
- {
- boolean bold = false;
-
- for ( FontData fontData : fontDatas )
- {
- if ( ( fontData.getStyle() & SWT.BOLD ) != SWT.NORMAL )
- {
- bold = true;
- }
- }
-
- return bold;
- }
-
-
- /**
- * Indicates if the given array of {@link FontData} is italic.
- *
- * @param fontDatas
- * the array
- * @return
- * <code>true</code> if the given array of {@link FontData} is italic, <code>false</code> if not.
- */
- private boolean isItalic( FontData[] fontDatas )
- {
- boolean italic = false;
-
- for ( FontData fontData : fontDatas )
- {
- if ( ( fontData.getStyle() & SWT.ITALIC ) != SWT.NORMAL )
- {
- italic = true;
- }
- }
-
- return italic;
}
Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/LogMessageConsole.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/LogMessageConsole.java?rev=650804&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/LogMessageConsole.java (added)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/LogMessageConsole.java Wed Apr 23 02:23:46 2008
@@ -0,0 +1,274 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.apacheds.experimentations;
+
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.console.MessageConsoleStream;
+
+
+/**
+ * TODO LogMessageConsole.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LogMessageConsole extends MessageConsole
+{
+ /** The preference store*/
+ private IPreferenceStore preferenceStore;
+
+ /** The stream for Debug level */
+ private MessageConsoleStream debugMessageConsoleStream;
+ /** The stream for Info level */
+ private MessageConsoleStream infoMessageConsoleStream;
+ /** The stream for Warn level */
+ private MessageConsoleStream warnMessageConsoleStream;
+ /** The stream for Error level */
+ private MessageConsoleStream errorMessageConsoleStream;
+ /** The stream for Fatal level */
+ private MessageConsoleStream fatalMessageConsoleStream;
+
+
+ /**
+ * Creates a new instance of LogMessageConsole.
+ *
+ * @param name
+ * console name
+ * @param imageDescriptor
+ * console image descriptor or null
+ */
+ public LogMessageConsole( String name, ImageDescriptor imageDescriptor )
+ {
+ super( name, imageDescriptor );
+
+ preferenceStore = Activator.getDefault().getPreferenceStore();
+ }
+
+
+ /**
+ * Creates a new instance of LogMessageConsole.
+ *
+ * @param name
+ * console name
+ */
+ public LogMessageConsole( String name )
+ {
+ super( name, null );
+
+ preferenceStore = Activator.getDefault().getPreferenceStore();
+ }
+
+
+ /**
+ * Gets the Debug stream.
+ *
+ * @return
+ * the Debug stream
+ */
+ public MessageConsoleStream getDebugConsoleMessageStream()
+ {
+ if ( debugMessageConsoleStream == null )
+ {
+ createDebugMessageConsoleStream();
+ }
+
+ return debugMessageConsoleStream;
+ }
+
+
+ /**
+ * Creates the Debug stream and set the Color and Font settings to it.
+ */
+ private void createDebugMessageConsoleStream()
+ {
+ // Creating the stream
+ debugMessageConsoleStream = newMessageStream();
+
+ // Setting the Color and Font settings
+ setColorAndFontSettingsToMessageConsoleStream( debugMessageConsoleStream,
+ PluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_COLOR, PluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_FONT );
+ }
+
+
+ /**
+ * Gets the Info stream.
+ *
+ * @return
+ * the Info stream
+ */
+ public MessageConsoleStream getInfoConsoleMessageStream()
+ {
+ if ( infoMessageConsoleStream == null )
+ {
+ createInfoMessageConsoleStream();
+ }
+
+ return infoMessageConsoleStream;
+ }
+
+
+ /**
+ * Creates the Info stream and set the Color and Font settings to it.
+ */
+ private void createInfoMessageConsoleStream()
+ {
+ // Creating the stream
+ infoMessageConsoleStream = newMessageStream();
+
+ // Setting the Color and Font settings
+ setColorAndFontSettingsToMessageConsoleStream( infoMessageConsoleStream,
+ PluginConstants.PREFS_COLORS_AND_FONTS_INFO_COLOR, PluginConstants.PREFS_COLORS_AND_FONTS_INFO_FONT );
+ }
+
+
+ /**
+ * Gets the Warn stream.
+ *
+ * @return
+ * the Warn stream
+ */
+ public MessageConsoleStream getWarnConsoleMessageStream()
+ {
+ if ( warnMessageConsoleStream == null )
+ {
+ createWarnMessageConsoleStream();
+ }
+
+ return warnMessageConsoleStream;
+ }
+
+
+ /**
+ * Creates the Warn stream and set the Color and Font settings to it.
+ */
+ private void createWarnMessageConsoleStream()
+ {
+ // Creating the stream
+ warnMessageConsoleStream = newMessageStream();
+
+ // Setting the Color and Font settings
+ setColorAndFontSettingsToMessageConsoleStream( warnMessageConsoleStream,
+ PluginConstants.PREFS_COLORS_AND_FONTS_WARN_COLOR, PluginConstants.PREFS_COLORS_AND_FONTS_WARN_FONT );
+ }
+
+
+ /**
+ * Gets the Error stream.
+ *
+ * @return
+ * the Error stream
+ */
+ public MessageConsoleStream getErrorConsoleMessageStream()
+ {
+ if ( errorMessageConsoleStream == null )
+ {
+ createErrorMessageConsoleStream();
+ }
+
+ return errorMessageConsoleStream;
+ }
+
+
+ /**
+ * Creates the Error stream and set the Color and Font settings to it.
+ */
+ private void createErrorMessageConsoleStream()
+ {
+ // Creating the stream
+ errorMessageConsoleStream = newMessageStream();
+
+ // Setting the Color and Font settings
+ setColorAndFontSettingsToMessageConsoleStream( errorMessageConsoleStream,
+ PluginConstants.PREFS_COLORS_AND_FONTS_ERROR_COLOR, PluginConstants.PREFS_COLORS_AND_FONTS_ERROR_FONT );
+ }
+
+
+ /**
+ * Gets the Fatal stream.
+ *
+ * @return
+ * the Fatal stream
+ */
+ public MessageConsoleStream getFatalConsoleMessageStream()
+ {
+ if ( fatalMessageConsoleStream == null )
+ {
+ createFatalMessageConsoleStream();
+ }
+
+ return fatalMessageConsoleStream;
+ }
+
+
+ /**
+ * Creates the Fatal stream and set the Color and Font settings to it.
+ */
+ private void createFatalMessageConsoleStream()
+ {
+ // Creating the stream
+ fatalMessageConsoleStream = newMessageStream();
+
+ // Setting the Color and Font settings
+ setColorAndFontSettingsToMessageConsoleStream( fatalMessageConsoleStream,
+ PluginConstants.PREFS_COLORS_AND_FONTS_FATAL_COLOR, PluginConstants.PREFS_COLORS_AND_FONTS_FATAL_FONT );
+ }
+
+
+ /**
+ * Sets the Color and Font settings to the given stream.
+ *
+ * @param messageConsoleStream
+ * the stream
+ * @param colorPreferenceName
+ * the preference name for the color
+ * @param fontPreferenceName
+ * the preference name for the font
+ */
+ private void setColorAndFontSettingsToMessageConsoleStream( MessageConsoleStream messageConsoleStream,
+ String colorPreferenceName, String fontPreferenceName )
+ {
+ // Getting Color and Font settings from the preference store
+ RGB rgb = PreferenceConverter.getColor( preferenceStore, colorPreferenceName );
+ FontData[] fontDatas = PreferenceConverter.getFontDataArray( preferenceStore, fontPreferenceName );
+
+ // Creating a style to apply to the font
+ int style = SWT.NORMAL;
+ if ( PreferenceStoreUtils.isBold( fontDatas ) )
+ {
+ style |= SWT.BOLD;
+ }
+ if ( PreferenceStoreUtils.isItalic( fontDatas ) )
+ {
+ style |= SWT.ITALIC;
+ }
+
+ // Applying settings to the stream
+ messageConsoleStream.setColor( new Color( Activator.getDefault().getWorkbench().getDisplay(), rgb ) );
+ messageConsoleStream.setFontStyle( style );
+ }
+}
Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PreferenceStoreUtils.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PreferenceStoreUtils.java?rev=650804&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PreferenceStoreUtils.java (added)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PreferenceStoreUtils.java Wed Apr 23 02:23:46 2008
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.apacheds.experimentations;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontData;
+
+public class PreferenceStoreUtils
+{
+ /**
+ * Indicates if the given array of {@link FontData} is italic.
+ *
+ * @param fontDatas
+ * the array
+ * @return
+ * <code>true</code> if the given array of {@link FontData} is italic, <code>false</code> if not.
+ */
+ public static boolean isItalic( FontData[] fontDatas )
+ {
+ boolean italic = false;
+
+ for ( FontData fontData : fontDatas )
+ {
+ if ( ( fontData.getStyle() & SWT.ITALIC ) != SWT.NORMAL )
+ {
+ italic = true;
+ }
+ }
+
+ return italic;
+ }
+
+ /**
+ * Indicates if the given array of {@link FontData} is bold.
+ *
+ * @param fontDatas
+ * the array
+ * @return
+ * <code>true</code> if the given array of {@link FontData} is bold, <code>false</code> if not.
+ */
+ public static boolean isBold( FontData[] fontDatas )
+ {
+ boolean bold = false;
+
+ for ( FontData fontData : fontDatas )
+ {
+ if ( ( fontData.getStyle() & SWT.BOLD ) != SWT.NORMAL )
+ {
+ bold = true;
+ }
+ }
+
+ return bold;
+ }
+}