directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r650516 - in /directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations: ./ src/main/java/org/apache/directory/studio/apacheds/experimentations/
Date Tue, 22 Apr 2008 13:23:52 GMT
Author: pamarcelot
Date: Tue Apr 22 06:23:41 2008
New Revision: 650516

URL: http://svn.apache.org/viewvc?rev=650516&view=rev
Log:
Added two PreferencePages, one for the Plugin and another for Colors and Fonts.

Added:
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ColorsAndFontsPage.java
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/MainPage.java
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PluginConstants.java
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PreferenceInitializer.java
Modified:
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/plugin.xml
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ConsoleDisplayMgr.java

Modified: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/plugin.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/plugin.xml?rev=650516&r1=650515&r2=650516&view=diff
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/plugin.xml
(original)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/plugin.xml
Tue Apr 22 06:23:41 2008
@@ -9,5 +9,25 @@
             name="ApacheDS Experimentations">
       </perspective>
    </extension>
+   <extension
+         point="org.eclipse.ui.preferencePages">
+      <page
+            class="org.apache.directory.studio.apacheds.experimentations.MainPage"
+            id="org.apache.directory.studio.apacheds.experimentations.MainPage"
+            name="Apache Directory Server">
+      </page>
+      <page
+            class="org.apache.directory.studio.apacheds.experimentations.ColorsAndFontsPage"
+            id="org.apache.directory.studio.apacheds.experimentations.ColorsAndFontsPage"
+            name="Colors and Fonts"
+            category="org.apache.directory.studio.apacheds.experimentations.MainPage">
+      </page>
+   </extension>
+   <extension
+         point="org.eclipse.core.runtime.preferences">
+      <initializer
+            class="org.apache.directory.studio.apacheds.experimentations.PreferenceInitializer">
+      </initializer>
+   </extension>
 
 </plugin>

Added: 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=650516&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ColorsAndFontsPage.java
(added)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ColorsAndFontsPage.java
Tue Apr 22 06:23:41 2008
@@ -0,0 +1,463 @@
+/*
+ *  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.ColorSelector;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+/**
+ * This class implements the Preference main page for the Apache Directory Server plugin.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ColorsAndFontsPage extends PreferencePage implements IWorkbenchPreferencePage
+{
+    // UI fields
+    private ColorSelector debugColorButton;
+    private Button debugBoldCheckbox;
+    private Button debugItalicCheckbox;
+    private ColorSelector infoColorButton;
+    private Button infoBoldCheckbox;
+    private Button infoItalicCheckbox;
+    private ColorSelector warnColorButton;
+    private Button warnBoldCheckbox;
+    private Button warnItalicCheckbox;
+    private ColorSelector errorColorButton;
+    private Button errorBoldCheckbox;
+    private Button errorItalicCheckbox;
+    private ColorSelector fatalColorButton;
+    private Button fatalBoldCheckbox;
+    private Button fatalItalicCheckbox;
+
+
+    /**
+     * Creates a new instance of MainPage.
+     */
+    public ColorsAndFontsPage()
+    {
+        super( "Colors and Fonts" );
+        setPreferenceStore( Activator.getDefault().getPreferenceStore() );
+        setDescription( "Colors and Fonts settings for the Apache Directory Server Plugin"
);
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+     */
+    protected Control createContents( Composite parent )
+    {
+        // Composite
+        Composite composite = new Composite( parent, SWT.NONE );
+        composite.setLayout( new GridLayout() );
+        composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+
+        // Console Group
+        Group consoleGroup = new Group( composite, SWT.NONE );
+        consoleGroup.setText( "Console" );
+        GridLayout consoleGroupLayout = new GridLayout( 4, false );
+        consoleGroup.setLayout( consoleGroupLayout );
+        consoleGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Debug
+        Label debugLabel = new Label( consoleGroup, SWT.NONE );
+        debugLabel.setText( "Debug:" );
+        debugColorButton = new ColorSelector( consoleGroup );
+        debugColorButton.getButton().setLayoutData( new GridData( SWT.RIGHT, SWT.NONE, true,
false ) );
+        debugBoldCheckbox = new Button( consoleGroup, SWT.CHECK );
+        debugBoldCheckbox.setText( "Bold" );
+        debugItalicCheckbox = new Button( consoleGroup, SWT.CHECK );
+        debugItalicCheckbox.setText( "Italic" );
+
+        // Info
+        Label infoLabel = new Label( consoleGroup, SWT.NONE );
+        infoLabel.setText( "Info:" );
+        infoColorButton = new ColorSelector( consoleGroup );
+        infoColorButton.getButton().setLayoutData( new GridData( SWT.RIGHT, SWT.NONE, true,
false ) );
+        infoBoldCheckbox = new Button( consoleGroup, SWT.CHECK );
+        infoBoldCheckbox.setText( "Bold" );
+        infoItalicCheckbox = new Button( consoleGroup, SWT.CHECK );
+        infoItalicCheckbox.setText( "Italic" );
+
+        // Warn
+        Label warnLabel = new Label( consoleGroup, SWT.NONE );
+        warnLabel.setText( "Warn:" );
+        warnColorButton = new ColorSelector( consoleGroup );
+        warnColorButton.getButton().setLayoutData( new GridData( SWT.RIGHT, SWT.NONE, true,
false ) );
+        warnBoldCheckbox = new Button( consoleGroup, SWT.CHECK );
+        warnBoldCheckbox.setText( "Bold" );
+        warnItalicCheckbox = new Button( consoleGroup, SWT.CHECK );
+        warnItalicCheckbox.setText( "Italic" );
+
+        // Error
+        Label errorLabel = new Label( consoleGroup, SWT.NONE );
+        errorLabel.setText( "Error:" );
+        errorColorButton = new ColorSelector( consoleGroup );
+        errorColorButton.getButton().setLayoutData( new GridData( SWT.RIGHT, SWT.NONE, true,
false ) );
+        errorBoldCheckbox = new Button( consoleGroup, SWT.CHECK );
+        errorBoldCheckbox.setText( "Bold" );
+        errorItalicCheckbox = new Button( consoleGroup, SWT.CHECK );
+        errorItalicCheckbox.setText( "Italic" );
+
+        // Fatal
+        Label fatalLabel = new Label( consoleGroup, SWT.NONE );
+        fatalLabel.setText( "Fatal:" );
+        fatalColorButton = new ColorSelector( consoleGroup );
+        fatalColorButton.getButton().setLayoutData( new GridData( SWT.RIGHT, SWT.NONE, true,
false ) );
+        fatalBoldCheckbox = new Button( consoleGroup, SWT.CHECK );
+        fatalBoldCheckbox.setText( "Bold" );
+        fatalItalicCheckbox = new Button( consoleGroup, SWT.CHECK );
+        fatalItalicCheckbox.setText( "Italic" );
+
+        initFromPreferences();
+
+        applyDialogFont( composite );
+        return composite;
+    }
+
+
+    /**
+     * Initializes the UI fields from the preferences values.
+     */
+    private void initFromPreferences()
+    {
+        // Debug
+        FontData[] fontDatas = PreferenceConverter.getFontDataArray( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_FONT );
+        RGB rgb = PreferenceConverter.getColor( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_COLOR );
+        setDebug( fontDatas, rgb );
+
+        // Info
+        fontDatas = PreferenceConverter.getFontDataArray( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_INFO_FONT );
+        rgb = PreferenceConverter.getColor( getPreferenceStore(), PluginConstants.PREFS_COLORS_AND_FONTS_INFO_COLOR
);
+        setInfo( fontDatas, rgb );
+
+        // Warn
+        fontDatas = PreferenceConverter.getFontDataArray( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_WARN_FONT );
+        rgb = PreferenceConverter.getColor( getPreferenceStore(), PluginConstants.PREFS_COLORS_AND_FONTS_WARN_COLOR
);
+        setWarn( fontDatas, rgb );
+
+        // Error
+        fontDatas = PreferenceConverter.getFontDataArray( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_ERROR_FONT );
+        rgb = PreferenceConverter.getColor( getPreferenceStore(), PluginConstants.PREFS_COLORS_AND_FONTS_ERROR_COLOR
);
+        setError( fontDatas, rgb );
+
+        // Fatal
+        fontDatas = PreferenceConverter.getFontDataArray( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_FATAL_FONT );
+        rgb = PreferenceConverter.getColor( getPreferenceStore(), PluginConstants.PREFS_COLORS_AND_FONTS_FATAL_COLOR
);
+        setFatal( fontDatas, rgb );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+     */
+    protected void performDefaults()
+    {
+        // Debug
+        FontData[] fontDatas = PreferenceConverter.getDefaultFontDataArray( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_FONT );
+        RGB rgb = PreferenceConverter.getDefaultColor( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_COLOR );
+        setDebug( fontDatas, rgb );
+
+        // Info
+        fontDatas = PreferenceConverter.getDefaultFontDataArray( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_INFO_FONT );
+        rgb = PreferenceConverter.getDefaultColor( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_INFO_COLOR );
+        setInfo( fontDatas, rgb );
+
+        // Warn
+        fontDatas = PreferenceConverter.getDefaultFontDataArray( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_WARN_FONT );
+        rgb = PreferenceConverter.getDefaultColor( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_WARN_COLOR );
+        setWarn( fontDatas, rgb );
+
+        // Error
+        fontDatas = PreferenceConverter.getDefaultFontDataArray( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_ERROR_FONT );
+        rgb = PreferenceConverter.getDefaultColor( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_ERROR_COLOR );
+        setError( fontDatas, rgb );
+
+        // Fatal
+        fontDatas = PreferenceConverter.getDefaultFontDataArray( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_FATAL_FONT );
+        rgb = PreferenceConverter.getDefaultColor( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_FATAL_COLOR );
+        setFatal( fontDatas, rgb );
+
+        super.performDefaults();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.preference.PreferencePage#performOk()
+     */
+    public boolean performOk()
+    {
+        // Debug
+        FontData[] fontDatas = PreferenceConverter.getFontDataArray( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_FONT );
+        setFontData( fontDatas, debugBoldCheckbox, debugItalicCheckbox );
+        PreferenceConverter.setValue( getPreferenceStore(), PluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_FONT,
+            fontDatas );
+        PreferenceConverter.setValue( getPreferenceStore(), PluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_COLOR,
+            debugColorButton.getColorValue() );
+
+        // Info
+        fontDatas = PreferenceConverter.getFontDataArray( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_INFO_FONT );
+        setFontData( fontDatas, infoBoldCheckbox, infoItalicCheckbox );
+        PreferenceConverter
+            .setValue( getPreferenceStore(), PluginConstants.PREFS_COLORS_AND_FONTS_INFO_FONT,
fontDatas );
+        PreferenceConverter.setValue( getPreferenceStore(), PluginConstants.PREFS_COLORS_AND_FONTS_INFO_COLOR,
+            infoColorButton.getColorValue() );
+
+        // Warn
+        fontDatas = PreferenceConverter.getFontDataArray( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_WARN_FONT );
+        setFontData( fontDatas, warnBoldCheckbox, warnItalicCheckbox );
+        PreferenceConverter
+            .setValue( getPreferenceStore(), PluginConstants.PREFS_COLORS_AND_FONTS_WARN_FONT,
fontDatas );
+        PreferenceConverter.setValue( getPreferenceStore(), PluginConstants.PREFS_COLORS_AND_FONTS_WARN_COLOR,
+            warnColorButton.getColorValue() );
+
+        // Error
+        fontDatas = PreferenceConverter.getFontDataArray( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_ERROR_FONT );
+        setFontData( fontDatas, errorBoldCheckbox, errorItalicCheckbox );
+        PreferenceConverter.setValue( getPreferenceStore(), PluginConstants.PREFS_COLORS_AND_FONTS_ERROR_FONT,
+            fontDatas );
+        PreferenceConverter.setValue( getPreferenceStore(), PluginConstants.PREFS_COLORS_AND_FONTS_ERROR_COLOR,
+            errorColorButton.getColorValue() );
+
+        // Error
+        fontDatas = PreferenceConverter.getFontDataArray( getPreferenceStore(),
+            PluginConstants.PREFS_COLORS_AND_FONTS_FATAL_FONT );
+        setFontData( fontDatas, fatalBoldCheckbox, fatalItalicCheckbox );
+        PreferenceConverter.setValue( getPreferenceStore(), PluginConstants.PREFS_COLORS_AND_FONTS_FATAL_FONT,
+            fontDatas );
+        PreferenceConverter.setValue( getPreferenceStore(), PluginConstants.PREFS_COLORS_AND_FONTS_FATAL_COLOR,
+            fatalColorButton.getColorValue() );
+
+        return super.performOk();
+    }
+
+
+    /**
+     * Set the font, bold and italic values to the Debug UI fields.
+     *
+     * @param fontDatas
+     *      the array of {@link FontData}
+     * @param rgb
+     *      the color
+     */
+    private void setDebug( FontData[] fontDatas, RGB rgb )
+    {
+        boolean bold = isBold( fontDatas );
+        boolean italic = isItalic( fontDatas );
+        debugColorButton.setColorValue( rgb );
+        debugBoldCheckbox.setSelection( bold );
+        debugItalicCheckbox.setSelection( italic );
+    }
+
+
+    /**
+     * Set the font, bold and italic values to the Info UI fields.
+     *
+     * @param fontDatas
+     *      the array of {@link FontData}
+     * @param rgb
+     *      the color
+     */
+    private void setInfo( FontData[] fontDatas, RGB rgb )
+    {
+        boolean bold = isBold( fontDatas );
+        boolean italic = isItalic( fontDatas );
+        infoColorButton.setColorValue( rgb );
+        infoBoldCheckbox.setSelection( bold );
+        infoItalicCheckbox.setSelection( italic );
+    }
+
+
+    /**
+     * Set the font, bold and italic values to the Warn UI fields.
+     *
+     * @param fontDatas
+     *      the array of {@link FontData}
+     * @param rgb
+     *      the color
+     */
+    private void setWarn( FontData[] fontDatas, RGB rgb )
+    {
+        boolean bold = isBold( fontDatas );
+        boolean italic = isItalic( fontDatas );
+        warnColorButton.setColorValue( rgb );
+        warnBoldCheckbox.setSelection( bold );
+        warnItalicCheckbox.setSelection( italic );
+    }
+
+
+    /**
+     * Set the font, bold and italic values to the Info UI fields.
+     *
+     * @param fontDatas
+     *      the array of {@link FontData}
+     * @param rgb
+     *      the color
+     */
+    private void setError( FontData[] fontDatas, RGB rgb )
+    {
+        boolean bold = isBold( fontDatas );
+        boolean italic = isItalic( fontDatas );
+        errorColorButton.setColorValue( rgb );
+        errorBoldCheckbox.setSelection( bold );
+        errorItalicCheckbox.setSelection( italic );
+    }
+
+
+    /**
+     * Set the font, bold and italic values to the Fatal UI fields.
+     *
+     * @param fontDatas
+     *      the array of {@link FontData}
+     * @param rgb
+     *      the color
+     * @param bgRgb
+     *      the background color
+     */
+    private void setFatal( FontData[] fontDatas, RGB rgb )
+    {
+        boolean bold = isBold( fontDatas );
+        boolean italic = 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;
+    }
+
+
+    /**
+     * Sets the bold and italic values to the array of {@link FontData}.
+     *
+     * @param fontDatas
+     *      the array of {@link FontData}
+     * @param boldButton
+     *      the bold button
+     * @param italicButton
+     *      the italic button
+     */
+    private void setFontData( FontData[] fontDatas, Button boldButton, Button italicButton
)
+    {
+        for ( FontData fontData : fontDatas )
+        {
+            int style = SWT.NORMAL;
+            if ( boldButton.getSelection() )
+            {
+                style |= SWT.BOLD;
+            }
+            if ( italicButton.getSelection() )
+            {
+                style |= SWT.ITALIC;
+            }
+
+            fontData.setStyle( style );
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+     */
+    public void init( IWorkbench workbench )
+    {
+        // Nothing to do
+    }
+}

Modified: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ConsoleDisplayMgr.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/ConsoleDisplayMgr.java?rev=650516&r1=650515&r2=650516&view=diff
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ConsoleDisplayMgr.java
(original)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ConsoleDisplayMgr.java
Tue Apr 22 06:23:41 2008
@@ -1 +1 @@
-/*
 *  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.dialogs.MessageDialog;
import org.eclipse.jface.text.IDocument;
impo
 rt org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPage;
import
org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import
org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleConstants;
import
org.eclipse.ui.console.MessageConsole;
import org.eclipse.ui.console.MessageConsoleStream;

/**
 * Create an instance of this class in any of your plugin classes.
 * 
 * Use it as follows
...
 * 
 * ConsoleDisplayMgr.getDefault().println("Some error msg", ConsoleDisplayMgr.MSG_ERROR);
* ...
 * ...
 * ConsoleDisplayMgr.getDefault().clear();
 * ...  
 */
public class ConsoleDisplayMgr
{
private static ConsoleDisplayMgr fDefault = null;
	private String fTitle = null;
	private
MessageConsole fMessageConsole = null;
	
	public static final int MSG_INFORMATION = 1;
	public
static final int MSG_ERROR = 2;
	public static final in
 t MSG_WARNING = 3;
		
	public ConsoleDisplayMgr(String messageTitle)
	{		
		fDefault = this;
	fTitle = messageTitle;
	}
	
	public static ConsoleDisplayMgr getDefault() {
		return fDefault;
}	
		
	public void println(String msg, int msgKind)
	{		
		if( msg == null ) return;
		
	
/* if console-view in Java-perspective is not active, then show it and
		 * then display the
message in the console attached to it */		
		if( !displayConsoleView() )
		{
			/*If an exception
occurs while displaying in the console, then just diplay atleast the same in a message-box
*/
			MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
"Error", msg);
			return;
		}
		
		/* display message on console */	
		getNewMessageConsoleStream(msgKind).println(msg);
			
	}
	
	public void clear()
	{		
		IDocument document = getMessageConsole().getDocument();
	if (document != null) {
			document.set("");
		}			
	}	
		
	private boolean displayConsoleView()
{
		try
		{
			IW
 orkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		if( activeWorkbenchWindow != null )
			{
				IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
			if( activePage != null )
					activePage.showView(IConsoleConstants.ID_CONSOLE_VIEW, null,
IWorkbenchPage.VIEW_VISIBLE);
			}
			
		} catch (PartInitException partEx) {			
			return
false;
		}
		
		return true;
	}
	
	private MessageConsoleStream getNewMessageConsoleStream(int
msgKind)
	{		
		int swtColorId = SWT.COLOR_DARK_GREEN;
		
		switch (msgKind)
		{
			case MSG_INFORMATION:
			swtColorId = SWT.COLOR_DARK_GREEN;				
				break;
			case MSG_ERROR:
				swtColorId = SWT.COLOR_DARK_MAGENTA;
			break;
			case MSG_WARNING:
				swtColorId = SWT.COLOR_DARK_BLUE;
				break;
			default:
			
		}	
		
		MessageConsoleStream msgConsoleStream = getMessageConsole().newMessageStream();
	
//		msgConsoleStream.setColor(Display.getCurrent().getSystemColor(swtColorId));
		return
ms
 gConsoleStream;
	}
	
	private MessageConsole getMessageConsole()
	{
		if( fMessageConsole
== null )
			createMessageConsoleStream(fTitle);	
		
		return fMessageConsole;
	}
		
	private
void createMessageConsoleStream(String title)
	{
		fMessageConsole = new MessageConsole(title,
null); 
		ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{ fMessageConsole
});
	}	
}
\ No newline at end of file
+/*
 *  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.dialogs.MessageDialog;
import org.eclipse.jface.text.IDocument;
impo
 rt org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPage;
import
org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import
org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleConstants;
import
org.eclipse.ui.console.MessageConsole;
import org.eclipse.ui.console.MessageConsoleStream;

/**
 * Create an instance of this class in any of your plugin classes.
 * 
 * Use it as follows
...
 * 
 * ConsoleDisplayMgr.getDefault().println("Some error msg", ConsoleDisplayMgr.MSG_ERROR);
* ...
 * ...
 * ConsoleDisplayMgr.getDefault().clear();
 * ...  
 */
public class ConsoleDisplayMgr
{
private static ConsoleDisplayMgr fDefault = null;
	private String fTitle = null;
	private
MessageConsole fMessageConsole = null;
	
	public static final int MSG_INFORMATION = 1;
	public
static final int MSG_ERROR = 2;
	public static final in
 t MSG_WARNING = 3;
		
	public ConsoleDisplayMgr(String messageTitle)
	{		
		fDefault = this;
	fTitle = messageTitle;
	}
	
	public static ConsoleDisplayMgr getDefault() {
		return fDefault;
}	
		
	public void println(String msg, int msgKind)
	{		
		if( msg == null ) return;
		
	
/* if console-view in Java-perspective is not active, then show it and
		 * then display the
message in the console attached to it */		
		if( !displayConsoleView() )
		{
			/*If an exception
occurs while displaying in the console, then just diplay atleast the same in a message-box
*/
			MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
"Error", msg);
			return;
		}
		
		/* display message on console */	
		getNewMessageConsoleStream(msgKind).println(msg);
			
	}
	
	
	
	public void clear()
	{		
		IDocument document = getMessageConsole().getDocument();
	if (document != null) {
			document.set("");
		}			
	}	
		
	private boolean displayConsoleView()
{
		try
		{
	
 		IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		if( activeWorkbenchWindow != null )
			{
				IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
			if( activePage != null )
					activePage.showView(IConsoleConstants.ID_CONSOLE_VIEW, null,
IWorkbenchPage.VIEW_VISIBLE);
			}
			
		} catch (PartInitException partEx) {			
			return
false;
		}
		
		return true;
	}
	
	private MessageConsoleStream getNewMessageConsoleStream(int
msgKind)
	{		
		int swtColorId = SWT.COLOR_DARK_GREEN;
		
		switch (msgKind)
		{
			case MSG_INFORMATION:
			swtColorId = SWT.COLOR_DARK_GREEN;				
				break;
			case MSG_ERROR:
				swtColorId = SWT.COLOR_DARK_MAGENTA;
			break;
			case MSG_WARNING:
				swtColorId = SWT.COLOR_DARK_BLUE;
				break;
			default:
			
		}	
		
		MessageConsoleStream msgConsoleStream = getMessageConsole().newMessageStream();
	
//		msgConsoleStream.setColor(Display.getCurrent().getSystemColor(swtColorId));
		retur
 n msgConsoleStream;
	}
	
	private MessageConsole getMessageConsole()
	{
		if( fMessageConsole
== null )
			createMessageConsoleStream(fTitle);	
		
		return fMessageConsole;
	}
		
	private
void createMessageConsoleStream(String title)
	{
		fMessageConsole = new MessageConsole(title,
null); 
		ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{ fMessageConsole
});
	}	
}
\ No newline at end of file

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/MainPage.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/MainPage.java?rev=650516&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/MainPage.java
(added)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/MainPage.java
Tue Apr 22 06:23:41 2008
@@ -0,0 +1,73 @@
+/*
+ *  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.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+/**
+ * This class implements the Preference main page for the Apache Directory Server plugin.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class MainPage extends PreferencePage implements IWorkbenchPreferencePage
+{
+
+    /**
+     * Creates a new instance of MainPage.
+     */
+    public MainPage()
+    {
+        super( "Apache Directory Server" );
+        setPreferenceStore( Activator.getDefault().getPreferenceStore() );
+        setDescription( "General settings for the Apache Directory Server Plugin" );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+     */
+    protected Control createContents( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NONE );
+        composite.setLayout( new GridLayout() );
+        composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+
+        return parent;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+     */
+    public void init( IWorkbench workbench )
+    {
+        // Nothing to do
+    }
+}

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PluginConstants.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/PluginConstants.java?rev=650516&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PluginConstants.java
(added)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PluginConstants.java
Tue Apr 22 06:23:41 2008
@@ -0,0 +1,58 @@
+/*
+ *  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;
+
+
+/**
+ * This interface stores all the constants used in the plugin.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface PluginConstants
+{
+    // -----------
+    // PREFERENCES
+    // -----------
+    /** The Preference ID for the Debug Font setting */
+    public static final String PREFS_COLORS_AND_FONTS_DEBUG_FONT = "org.apache.directory.studio.apacheds.experimentations.prefs.colorAndFonts.debugFont";
+    /** The Preference ID for the Debug Color setting */
+    public static final String PREFS_COLORS_AND_FONTS_DEBUG_COLOR = "org.apache.directory.studio.apacheds.experimentations.prefs.colorAndFonts.debugColor";
+
+    /** The Preference ID for the Info Font setting */
+    public static final String PREFS_COLORS_AND_FONTS_INFO_FONT = "org.apache.directory.studio.apacheds.experimentations.prefs.colorAndFonts.infoFont";
+    /** The Preference ID for the Info Color setting */
+    public static final String PREFS_COLORS_AND_FONTS_INFO_COLOR = "org.apache.directory.studio.apacheds.experimentations.prefs.colorAndFonts.infoColor";
+
+    /** The Preference ID for the Warn Font setting */
+    public static final String PREFS_COLORS_AND_FONTS_WARN_FONT = "org.apache.directory.studio.apacheds.experimentations.prefs.colorAndFonts.warnFont";
+    /** The Preference ID for the Warn Color setting */
+    public static final String PREFS_COLORS_AND_FONTS_WARN_COLOR = "org.apache.directory.studio.apacheds.experimentations.prefs.colorAndFonts.warnColor";
+
+    /** The Preference ID for the Error Font settings */
+    public static final String PREFS_COLORS_AND_FONTS_ERROR_FONT = "org.apache.directory.studio.apacheds.experimentations.prefs.colorAndFonts.errorFont";
+    /** The Preference ID for the Error Color setting */
+    public static final String PREFS_COLORS_AND_FONTS_ERROR_COLOR = "org.apache.directory.studio.apacheds.experimentations.prefs.colorAndFonts.errorColor";
+
+    /** The Preference ID for the Fatal Font setting */
+    public static final String PREFS_COLORS_AND_FONTS_FATAL_FONT = "org.apache.directory.studio.apacheds.experimentations.prefs.colorAndFonts.fatalFont";
+    /** The Preference ID for the Fatal Colors setting */
+    public static final String PREFS_COLORS_AND_FONTS_FATAL_COLOR = "org.apache.directory.studio.apacheds.experimentations.prefs.colorAndFonts.fatalColor";
+}

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PreferenceInitializer.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/PreferenceInitializer.java?rev=650516&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PreferenceInitializer.java
(added)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/PreferenceInitializer.java
Tue Apr 22 06:23:41 2008
@@ -0,0 +1,76 @@
+/*
+ *  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.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * This class is used to set default preference values.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PreferenceInitializer extends AbstractPreferenceInitializer
+{
+    /* (non-Javadoc)
+     * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+     */
+    public void initializeDefaultPreferences()
+    {
+        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+
+        // Fonts
+        FontData[] fontData = Display.getDefault().getSystemFont().getFontData();
+        FontData fontDataNormal = new FontData( fontData[0].getName(), fontData[0].getHeight(),
SWT.NORMAL );
+        FontData fontDataItalic = new FontData( fontData[0].getName(), fontData[0].getHeight(),
SWT.ITALIC );
+        FontData fontDataBold = new FontData( fontData[0].getName(), fontData[0].getHeight(),
SWT.BOLD );
+
+        // Colors
+        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 );
+
+        // Debug
+        PreferenceConverter.setDefault( store, PluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_FONT,
fontDataItalic );
+        PreferenceConverter.setDefault( store, PluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_COLOR,
rgbBlue );
+        // Info
+        PreferenceConverter.setDefault( store, PluginConstants.PREFS_COLORS_AND_FONTS_INFO_FONT,
fontDataItalic );
+        PreferenceConverter.setDefault( store, PluginConstants.PREFS_COLORS_AND_FONTS_INFO_COLOR,
rgbGreen );
+        // Warn
+        PreferenceConverter.setDefault( store, PluginConstants.PREFS_COLORS_AND_FONTS_WARN_FONT,
fontDataNormal );
+        PreferenceConverter.setDefault( store, PluginConstants.PREFS_COLORS_AND_FONTS_WARN_COLOR,
rgbOrange );
+        // Error
+        PreferenceConverter.setDefault( store, PluginConstants.PREFS_COLORS_AND_FONTS_ERROR_FONT,
fontDataBold );
+        PreferenceConverter.setDefault( store, PluginConstants.PREFS_COLORS_AND_FONTS_ERROR_COLOR,
rgbRed );
+        // Fatal
+        PreferenceConverter.setDefault( store, PluginConstants.PREFS_COLORS_AND_FONTS_FATAL_FONT,
fontDataBold );
+        PreferenceConverter.setDefault( store, PluginConstants.PREFS_COLORS_AND_FONTS_FATAL_COLOR,
rgbDarkRed );
+    }
+}



Mime
View raw message