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 2007/08/01 16:52:03 UTC

svn commit: r561817 [2/2] - in /directory/studio/trunk/studio-apacheds-schemaeditor: ./ src/main/java/org/apache/directory/studio/apacheds/schemaeditor/ src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/ src/main/java/org/apach...

Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/HierarchyViewPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/HierarchyViewPreferencePage.java?view=auto&rev=561817
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/HierarchyViewPreferencePage.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/HierarchyViewPreferencePage.java Wed Aug  1 07:51:59 2007
@@ -0,0 +1,432 @@
+/*
+ *  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.schemaeditor.view.preferences;
+
+
+import org.apache.directory.studio.apacheds.schemaeditor.Activator;
+import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+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.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+/**
+ * This class implements the Preference page for the Hierarchy View
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class HierarchyViewPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+    /** The preference page ID */
+    public static final String ID = Activator.PLUGIN_ID + ".preferences.hierarchyView"; //$NON-NLS-1$
+
+    /** The First Name category */
+    private static final String FIRST_NAME = "First Name";
+
+    /** The All Aliases category */
+    private static final String ALL_ALIASES = "All Aliases";
+
+    /** The OID category */
+    private static final String OID = "OID";
+
+    // UI fields
+    private Combo labelCombo;
+    private Button limitButton;
+    private Text lengthText;
+    private Button secondaryLabelButtonDisplay;
+    private Combo secondaryLabelCombo;
+    private Button secondaryLabelLimitButton;
+    private Text secondaryLabelLengthText;
+
+
+    /**
+     * Creates a new instance of HierarchyViewPreferencePage.
+     */
+    public HierarchyViewPreferencePage()
+    {
+        super();
+        super.setPreferenceStore( Activator.getDefault().getPreferenceStore() );
+        super.setDescription( "General settings for the Hierarchy View of the Schema Editor 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 ) );
+
+        // Label Group
+        Group labelGroup = new Group( composite, SWT.NONE );
+        labelGroup.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+        labelGroup.setText( "Label" );
+        labelGroup.setLayout( new GridLayout() );
+        Composite labelGroupComposite = new Composite( labelGroup, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        gl.marginHeight = gl.marginWidth = 0;
+        labelGroupComposite.setLayout( gl );
+        labelGroupComposite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+        // Label row composite
+        Composite labelComposite = new Composite( labelGroupComposite, SWT.NONE );
+        gl = new GridLayout( 3, false );
+        gl.marginHeight = gl.marginWidth = 0;
+        labelComposite.setLayout( gl );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 1;
+        labelComposite.setLayoutData( gd );
+
+        // Use Label
+        Label useLabel = new Label( labelComposite, SWT.NONE );
+        useLabel.setText( "Use" );
+
+        // Label Combo
+        labelCombo = new Combo( labelComposite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER );
+        labelCombo.setLayoutData( new GridData() );
+        labelCombo.setItems( new String[]
+            { FIRST_NAME, ALL_ALIASES, OID } );
+        labelCombo.setEnabled( true );
+
+        // As label Label
+        Label asLabel = new Label( labelComposite, SWT.NONE );
+        asLabel.setText( "as label." );
+
+        // Abbreviate row composite
+        Composite abbreviateComposite = new Composite( labelGroupComposite, SWT.NONE );
+        gl = new GridLayout( 3, false );
+        gl.marginHeight = gl.marginWidth = 0;
+        abbreviateComposite.setLayout( gl );
+        gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 1;
+        abbreviateComposite.setLayoutData( gd );
+
+        // Limit label lenght to Label
+        limitButton = new Button( abbreviateComposite, SWT.CHECK );
+        limitButton.setText( "Limit label length to" );
+        gd = new GridData();
+        gd.horizontalSpan = 1;
+        limitButton.setLayoutData( gd );
+
+        // Lenght Text
+        lengthText = new Text( abbreviateComposite, SWT.NONE | SWT.BORDER );
+        GridData gridData = new GridData();
+        gridData.horizontalSpan = 1;
+        gridData.widthHint = 9 * 3;
+        lengthText.setLayoutData( gridData );
+        lengthText.setTextLimit( 3 );
+        lengthText.addVerifyListener( new VerifyListener()
+        {
+            public void verifyText( VerifyEvent e )
+            {
+                if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
+                {
+                    e.doit = false;
+                }
+                if ( "".equals( lengthText.getText() ) && e.text.matches( "[0]" ) ) //$NON-NLS-1$ //$NON-NLS-2$
+                {
+                    e.doit = false;
+                }
+            }
+        } );
+
+        // Characters Label
+        Label charactersLabel = new Label( abbreviateComposite, SWT.NONE );
+        charactersLabel.setText( "characters." );
+
+        // Secondary Label Group
+        Group secondaryLabelGroup = new Group( composite, SWT.NONE );
+        secondaryLabelGroup.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+        secondaryLabelGroup.setText( "Secondary label" );
+        secondaryLabelGroup.setLayout( new GridLayout() );
+        Composite secondaryLabelGroupComposite = new Composite( secondaryLabelGroup, SWT.NONE );
+        gl = new GridLayout( 1, false );
+        gl.marginHeight = gl.marginWidth = 0;
+        secondaryLabelGroupComposite.setLayout( gl );
+        secondaryLabelGroupComposite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+        secondaryLabelButtonDisplay = new Button( secondaryLabelGroupComposite, SWT.CHECK );
+        secondaryLabelButtonDisplay.setText( "Display secondary label." );
+
+        // Label row composite
+        Composite secondaryLabelComposite = new Composite( secondaryLabelGroupComposite, SWT.NONE );
+        gl = new GridLayout( 3, false );
+        gl.marginHeight = gl.marginWidth = 0;
+        secondaryLabelComposite.setLayout( gl );
+        gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 1;
+        secondaryLabelComposite.setLayoutData( gd );
+
+        // Use Label
+        Label useLabel2 = new Label( secondaryLabelComposite, SWT.NONE );
+        useLabel2.setText( "Use" );
+
+        // Label Combo
+        secondaryLabelCombo = new Combo( secondaryLabelComposite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER );
+        secondaryLabelCombo.setLayoutData( new GridData() );
+        secondaryLabelCombo.setItems( new String[]
+            { FIRST_NAME, ALL_ALIASES, OID } );
+        secondaryLabelCombo.setEnabled( true );
+
+        // As label Label
+        Label asLabel2 = new Label( secondaryLabelComposite, SWT.NONE );
+        asLabel2.setText( "as secondary label." );
+
+        // Abbreviate row composite
+        Composite abbreviateComposite2 = new Composite( secondaryLabelGroup, SWT.NONE );
+        gl = new GridLayout( 3, false );
+        gl.marginHeight = gl.marginWidth = 0;
+        abbreviateComposite2.setLayout( gl );
+        gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 1;
+        abbreviateComposite2.setLayoutData( gd );
+
+        // Limit label length to Label
+        secondaryLabelLimitButton = new Button( abbreviateComposite2, SWT.CHECK );
+        secondaryLabelLimitButton.setText( "Limit secondary label length to" );
+        gd = new GridData();
+        gd.horizontalSpan = 1;
+        secondaryLabelLimitButton.setLayoutData( gd );
+
+        // Length Text
+        secondaryLabelLengthText = new Text( abbreviateComposite2, SWT.NONE | SWT.BORDER );
+        gridData = new GridData();
+        gridData.horizontalSpan = 1;
+        gridData.widthHint = 9 * 3;
+        secondaryLabelLengthText.setLayoutData( gridData );
+        secondaryLabelLengthText.setTextLimit( 3 );
+        secondaryLabelLengthText.addVerifyListener( new VerifyListener()
+        {
+            public void verifyText( VerifyEvent e )
+            {
+                if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
+                {
+                    e.doit = false;
+                }
+                if ( "".equals( secondaryLabelLengthText.getText() ) && e.text.matches( "[0]" ) ) //$NON-NLS-1$ //$NON-NLS-2$
+                {
+                    e.doit = false;
+                }
+            }
+        } );
+
+        // Characters Label
+        Label secondaryLabelcharactersLabel = new Label( abbreviateComposite2, SWT.NONE );
+        secondaryLabelcharactersLabel.setText( "characters." );
+
+        initFieldsFromPreferences();
+
+        initListeners();
+
+        applyDialogFont( parent );
+
+        return parent;
+    }
+
+
+    /**
+     * Initializes the fields from the preferences store.
+     */
+    private void initFieldsFromPreferences()
+    {
+        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+
+        labelCombo.select( store.getInt( PluginConstants.PREFS_HIERARCHY_VIEW_LABEL ) );
+        limitButton.setSelection( store.getBoolean( PluginConstants.PREFS_HIERARCHY_VIEW_ABBREVIATE ) );
+        lengthText.setEnabled( limitButton.getSelection() );
+        lengthText.setText( store.getString( PluginConstants.PREFS_HIERARCHY_VIEW_ABBREVIATE_MAX_LENGTH ) );
+
+        secondaryLabelButtonDisplay.setSelection( store
+            .getBoolean( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_DISPLAY ) );
+        secondaryLabelCombo.select( store.getInt( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL ) );
+        secondaryLabelLimitButton.setSelection( store
+            .getBoolean( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE ) );
+        secondaryLabelLengthText.setText( store
+            .getString( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH ) );
+        if ( store.getBoolean( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_DISPLAY ) )
+        {
+            secondaryLabelCombo.setEnabled( true );
+            secondaryLabelLimitButton.setEnabled( true );
+            secondaryLabelLengthText.setEnabled( secondaryLabelLimitButton.getSelection() );
+        }
+        else
+        {
+            secondaryLabelCombo.setEnabled( false );
+            secondaryLabelLimitButton.setEnabled( false );
+            secondaryLabelLengthText.setEnabled( false );
+        }
+    }
+
+
+    /**
+     * Initializes the listeners.
+     */
+    private void initListeners()
+    {
+        limitButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                lengthText.setEnabled( limitButton.getSelection() );
+            }
+        } );
+
+        secondaryLabelButtonDisplay.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                if ( secondaryLabelButtonDisplay.getSelection() )
+                {
+                    secondaryLabelCombo.setEnabled( true );
+                    secondaryLabelLimitButton.setEnabled( true );
+                    secondaryLabelLengthText.setEnabled( secondaryLabelLimitButton.getSelection() );
+                }
+                else
+                {
+                    secondaryLabelCombo.setEnabled( false );
+                    secondaryLabelLimitButton.setEnabled( false );
+                    secondaryLabelLengthText.setEnabled( false );
+                }
+            }
+        } );
+
+        secondaryLabelLimitButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                secondaryLabelLengthText.setEnabled( secondaryLabelLimitButton.getSelection() );
+            }
+        } );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+     */
+    protected void performDefaults()
+    {
+        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+
+        labelCombo.select( store.getDefaultInt( PluginConstants.PREFS_HIERARCHY_VIEW_LABEL ) );
+        limitButton.setSelection( store.getDefaultBoolean( PluginConstants.PREFS_HIERARCHY_VIEW_ABBREVIATE ) );
+        lengthText.setEnabled( limitButton.getSelection() );
+        lengthText.setText( store.getDefaultString( PluginConstants.PREFS_HIERARCHY_VIEW_ABBREVIATE_MAX_LENGTH ) );
+
+        secondaryLabelButtonDisplay.setSelection( store
+            .getDefaultBoolean( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_DISPLAY ) );
+        secondaryLabelCombo.select( store.getDefaultInt( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL ) );
+        secondaryLabelLimitButton.setSelection( store
+            .getDefaultBoolean( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE ) );
+        secondaryLabelLengthText.setText( store
+            .getDefaultString( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH ) );
+
+        if ( secondaryLabelButtonDisplay.getSelection() )
+        {
+            secondaryLabelCombo.setEnabled( true );
+            secondaryLabelLimitButton.setEnabled( true );
+            secondaryLabelLengthText.setEnabled( secondaryLabelLimitButton.getSelection() );
+        }
+        else
+        {
+            secondaryLabelCombo.setEnabled( false );
+            secondaryLabelLimitButton.setEnabled( false );
+            secondaryLabelLengthText.setEnabled( false );
+        }
+
+        super.performDefaults();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.preference.PreferencePage#performOk()
+     */
+    public boolean performOk()
+    {
+        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+
+        if ( labelCombo.getItem( labelCombo.getSelectionIndex() ).equals( FIRST_NAME ) )
+        {
+            store.setValue( PluginConstants.PREFS_HIERARCHY_VIEW_LABEL,
+                PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME );
+        }
+        else if ( labelCombo.getItem( labelCombo.getSelectionIndex() ).equals( ALL_ALIASES ) )
+        {
+            store.setValue( PluginConstants.PREFS_HIERARCHY_VIEW_LABEL,
+                PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES );
+        }
+        else if ( labelCombo.getItem( labelCombo.getSelectionIndex() ).equals( OID ) )
+        {
+            store.setValue( PluginConstants.PREFS_HIERARCHY_VIEW_LABEL, PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_OID );
+        }
+        store.setValue( PluginConstants.PREFS_HIERARCHY_VIEW_ABBREVIATE, limitButton.getSelection() );
+        store.setValue( PluginConstants.PREFS_HIERARCHY_VIEW_ABBREVIATE_MAX_LENGTH, lengthText.getText() );
+
+        store.setValue( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_DISPLAY, secondaryLabelButtonDisplay
+            .getSelection() );
+        if ( secondaryLabelCombo.getItem( secondaryLabelCombo.getSelectionIndex() ).equals( FIRST_NAME ) )
+        {
+            store.setValue( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL,
+                PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME );
+        }
+        else if ( secondaryLabelCombo.getItem( secondaryLabelCombo.getSelectionIndex() ).equals( ALL_ALIASES ) )
+        {
+            store.setValue( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL,
+                PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES );
+        }
+        else if ( secondaryLabelCombo.getItem( secondaryLabelCombo.getSelectionIndex() ).equals( OID ) )
+        {
+            store.setValue( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL,
+                PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_OID );
+        }
+        store.setValue( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE, secondaryLabelLimitButton
+            .getSelection() );
+        store.setValue( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH,
+            secondaryLabelLengthText.getText() );
+
+        return true;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+     */
+    public void init( IWorkbench workbench )
+    {
+    }
+}

Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyView.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyView.java?view=auto&rev=561817
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyView.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyView.java Wed Aug  1 07:51:59 2007
@@ -0,0 +1,114 @@
+/*
+ *  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.schemaeditor.view.views;
+
+
+import org.apache.directory.studio.apacheds.schemaeditor.Activator;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.HierarchyViewController;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+
+
+/**
+ * This class implements the Hierarchy View.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class HierarchyView extends ViewPart
+{
+    /** The view's ID */
+    public static final String ID = Activator.PLUGIN_ID + ".view.HierarchyView"; //$NON-NLS-1$
+
+    /** The tree viewer */
+    private TreeViewer viewer;
+
+    /** The content provider */
+    private HierarchyViewContentProvider contentProvider;
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+     */
+    public void createPartControl( Composite parent )
+    {
+        initViewer( parent );
+
+        new HierarchyViewController( this );
+    }
+
+
+    /**
+     * Initializes the Viewer
+     *
+     * @param parent
+     *      the parent Composite
+     */
+    private void initViewer( Composite parent )
+    {
+        viewer = new TreeViewer( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER );
+        contentProvider = new HierarchyViewContentProvider();
+        viewer.setContentProvider( contentProvider );
+        viewer.setLabelProvider( new DecoratingLabelProvider( new HierarchyViewLabelProvider(), Activator.getDefault()
+            .getWorkbench().getDecoratorManager().getLabelDecorator() ) );
+        viewer.getTree().setEnabled( false );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+     */
+    public void setFocus()
+    {
+        viewer.getControl().setFocus();
+    }
+
+
+    /**
+     * Gets the TreeViewer
+     *
+     * @return
+     *      the TreeViewer
+     */
+    public TreeViewer getViewer()
+    {
+        return viewer;
+    }
+
+
+    /**
+     * Refreshes the viewer.
+     */
+    public void refresh()
+    {
+        viewer.refresh();
+        viewer.expandAll();
+    }
+
+
+    public void setInput( Object input )
+    {
+        viewer.setInput( input );
+        viewer.expandAll();
+    }
+}

Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyViewContentProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyViewContentProvider.java?view=auto&rev=561817
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyViewContentProvider.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyViewContentProvider.java Wed Aug  1 07:51:59 2007
@@ -0,0 +1,228 @@
+/*
+ *  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.schemaeditor.view.views;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.apacheds.schemaeditor.Activator;
+import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.AttributeTypeWrapper;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.ObjectClassWrapper;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.TreeNode;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+
+/**
+ * This class implements the Content Provider for the Schemas View.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class HierarchyViewContentProvider implements IStructuredContentProvider, ITreeContentProvider
+{
+    /** The SchemaHandler */
+    private SchemaHandler schemaHandler;
+
+    List<AttributeTypeImpl> attributeTypes;
+    List<ObjectClassImpl> objectClasses;
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+     */
+    public Object[] getElements( Object inputElement )
+    {
+        return getChildren( inputElement );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+     */
+    public Object[] getChildren( Object parentElement )
+    {
+        int mode = Activator.getDefault().getDialogSettings().getInt( PluginConstants.PREFS_HIERARCHY_VIEW_MODE );
+        List<TreeNode> children = null;
+
+        schemaHandler = Activator.getDefault().getSchemaHandler();
+        attributeTypes = schemaHandler.getAttributeTypes();
+        objectClasses = schemaHandler.getObjectClasses();
+
+        if ( parentElement instanceof ObjectClassImpl )
+        {
+            ObjectClassImpl oc = ( ObjectClassImpl ) parentElement;
+
+            ObjectClassWrapper ocw = new ObjectClassWrapper( oc, null );
+            children = new ArrayList<TreeNode>();
+            children.add( ocw );
+        }
+        else if ( parentElement instanceof AttributeTypeImpl )
+        {
+            AttributeTypeImpl at = ( AttributeTypeImpl ) parentElement;
+
+            AttributeTypeWrapper atw = new AttributeTypeWrapper( at, null );
+            children = new ArrayList<TreeNode>();
+            children.add( atw );
+        }
+        else if ( parentElement instanceof ObjectClassWrapper )
+        {
+            ObjectClassWrapper ocw = ( ObjectClassWrapper ) parentElement;
+            ObjectClassImpl oc = ocw.getObjectClass();
+
+            if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUPERTYPE )
+            {
+                String[] superiors = oc.getSuperClassesNames();
+                for ( String superior : superiors )
+                {
+                    if ( superior != null || "".equals( superior ) ) //$NON-NLS-1$
+                    {
+                        ObjectClassImpl supOC = schemaHandler.getObjectClass( superior );
+                        if ( supOC != null )
+                        {
+                            ObjectClassWrapper supOCW = new ObjectClassWrapper( supOC, ocw );
+                            ocw.addChild( supOCW );
+                        }
+                    }
+                }
+            }
+            else if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUBTYPE )
+            {
+                for ( ObjectClassImpl objectClass : objectClasses )
+                {
+                    String[] superiors = objectClass.getSuperClassesNames();
+                    for ( String superior : superiors )
+                    {
+                        if ( superior != null || "".equals( superior ) ) //$NON-NLS-1$
+                        {
+                            ObjectClassImpl supOC = schemaHandler.getObjectClass( superior );
+                            if ( supOC != null && oc.equals( supOC ) )
+                            {
+                                ObjectClassWrapper supOCW = new ObjectClassWrapper( objectClass, ocw );
+                                ocw.addChild( supOCW );
+                            }
+                        }
+                    }
+                }
+            }
+
+            children = ocw.getChildren();
+        }
+        else if ( parentElement instanceof AttributeTypeWrapper )
+        {
+            AttributeTypeWrapper atw = ( AttributeTypeWrapper ) parentElement;
+            AttributeTypeImpl at = atw.getAttributeType();
+
+            if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUPERTYPE )
+            {
+                String superior = at.getSuperiorName();
+                if ( superior != null || "".equals( superior ) ) //$NON-NLS-1$
+                {
+                    AttributeTypeImpl supAT = schemaHandler.getAttributeType( superior );
+                    if ( supAT != null )
+                    {
+                        AttributeTypeWrapper supATW = new AttributeTypeWrapper( supAT, atw );
+                        atw.addChild( supATW );
+                    }
+                }
+            }
+            else if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUBTYPE )
+            {
+                for ( AttributeTypeImpl attributeType : attributeTypes )
+                {
+                    String superior = attributeType.getSuperiorName();
+                    if ( superior != null && !"".equals( superior ) ) //$NON-NLS-1$
+                    {
+                        AttributeTypeImpl supAT = schemaHandler.getAttributeType( superior );
+                        if ( supAT != null && at.equals( supAT ) )
+                        {
+                            AttributeTypeWrapper supATW = new AttributeTypeWrapper( attributeType, atw );
+                            atw.addChild( supATW );
+                        }
+                    }
+                }
+            }
+
+            children = atw.getChildren();
+        }
+
+        if ( children == null )
+        {
+            return new Object[0];
+        }
+        else
+        {
+            return children.toArray();
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+     */
+    public Object getParent( Object element )
+    {
+        if ( element instanceof TreeNode )
+        {
+            return ( ( TreeNode ) element ).getParent();
+        }
+
+        // Default
+        return null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+     */
+    public boolean hasChildren( Object element )
+    {
+        if ( element instanceof TreeNode )
+        {
+            return true;
+        }
+
+        // Default
+        return false;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+     */
+    public void dispose()
+    {
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+     */
+    public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+    {
+    }
+}

Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyViewLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyViewLabelProvider.java?view=auto&rev=561817
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyViewLabelProvider.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyViewLabelProvider.java Wed Aug  1 07:51:59 2007
@@ -0,0 +1,288 @@
+/*
+ *  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.schemaeditor.view.views;
+
+
+import org.apache.directory.studio.apacheds.schemaeditor.Activator;
+import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
+import org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.view.ViewUtils;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.AttributeTypeWrapper;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.ObjectClassWrapper;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class implements the LabelProvider for the Hierarchy View.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class HierarchyViewLabelProvider extends LabelProvider
+{
+    private static final String NONE = "(None)";
+
+    /** The preferences store */
+    private IPreferenceStore store;
+
+
+    /**
+     * Creates a new instance of SchemasViewLabelProvider.
+     */
+    public HierarchyViewLabelProvider()
+    {
+        store = Activator.getDefault().getPreferenceStore();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+     */
+    public String getText( Object obj )
+    {
+        String label = ""; //$NON-NLS-1$
+
+        int labelValue = store.getInt( PluginConstants.PREFS_HIERARCHY_VIEW_LABEL );
+        boolean abbreviate = store.getBoolean( PluginConstants.PREFS_HIERARCHY_VIEW_ABBREVIATE );
+        int abbreviateMaxLength = store.getInt( PluginConstants.PREFS_HIERARCHY_VIEW_ABBREVIATE_MAX_LENGTH );
+        boolean secondaryLabelDisplay = store.getBoolean( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_DISPLAY );
+        int secondaryLabelValue = store.getInt( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL );
+        boolean secondaryLabelAbbreviate = store
+            .getBoolean( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE );
+        int secondaryLabelAbbreviateMaxLength = store
+            .getInt( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH );
+
+        if ( obj instanceof AttributeTypeWrapper )
+        {
+            AttributeTypeImpl at = ( ( AttributeTypeWrapper ) obj ).getAttributeType();
+
+            // Label
+            if ( labelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME )
+            {
+                String[] names = at.getNames();
+                if ( ( names != null ) && ( names.length > 0 ) )
+                {
+                    label = names[0];
+                }
+                else
+                {
+                    label = NONE;
+                }
+            }
+            else if ( labelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES )
+            {
+                String[] names = at.getNames();
+                if ( ( names != null ) && ( names.length > 0 ) )
+                {
+                    label = ViewUtils.concateAliases( names );
+                }
+                else
+                {
+                    label = NONE;
+                }
+            }
+            else if ( labelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_OID )
+            {
+                label = at.getOid();
+            }
+            else
+            // Default
+            {
+                String[] names = at.getNames();
+                if ( ( names != null ) && ( names.length > 0 ) )
+                {
+                    label = names[0];
+                }
+                else
+                {
+                    label = NONE;
+                }
+            }
+
+            // Abbreviate
+            if ( abbreviate && ( abbreviateMaxLength < label.length() ) )
+            {
+                label = label.substring( 0, abbreviateMaxLength ) + "..."; //$NON-NLS-1$
+            }
+        }
+        else if ( obj instanceof ObjectClassWrapper )
+        {
+            ObjectClassImpl oc = ( ( ObjectClassWrapper ) obj ).getObjectClass();
+
+            // Label
+            if ( labelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME )
+            {
+                String[] names = oc.getNames();
+                if ( ( names != null ) && ( names.length > 0 ) )
+                {
+                    label = names[0];
+                }
+                else
+                {
+                    label = NONE;
+                }
+            }
+            else if ( labelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES )
+            {
+                String[] names = oc.getNames();
+                if ( ( names != null ) && ( names.length > 0 ) )
+                {
+                    label = ViewUtils.concateAliases( names );
+                }
+                else
+                {
+                    label = NONE;
+                }
+            }
+            else if ( labelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_OID )
+            {
+                label = oc.getOid();
+            }
+            else
+            // Default
+            {
+                String[] names = oc.getNames();
+                if ( ( names != null ) && ( names.length > 0 ) )
+                {
+                    label = names[0];
+                }
+                else
+                {
+                    label = NONE;
+                }
+            }
+
+            // Abbreviate
+            if ( abbreviate && ( abbreviateMaxLength < label.length() ) )
+            {
+                label = label.substring( 0, abbreviateMaxLength ) + "..."; //$NON-NLS-1$
+            }
+        }
+
+        // Secondary Label
+        if ( secondaryLabelDisplay )
+        {
+            String secondaryLabel = ""; //$NON-NLS-1$
+            if ( obj instanceof AttributeTypeWrapper )
+            {
+                AttributeTypeImpl at = ( ( AttributeTypeWrapper ) obj ).getAttributeType();
+
+                if ( secondaryLabelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME )
+                {
+                    String[] names = at.getNames();
+                    if ( ( names != null ) && ( names.length > 0 ) )
+                    {
+                        secondaryLabel = names[0];
+                    }
+                    else
+                    {
+                        secondaryLabel = NONE;
+                    }
+                }
+                else if ( secondaryLabelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES )
+                {
+                    String[] names = at.getNames();
+                    if ( ( names != null ) && ( names.length > 0 ) )
+                    {
+                        secondaryLabel = ViewUtils.concateAliases( names );
+                    }
+                    else
+                    {
+                        secondaryLabel = NONE;
+                    }
+                }
+                else if ( secondaryLabelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_OID )
+                {
+                    secondaryLabel = at.getOid();
+                }
+            }
+            else if ( obj instanceof ObjectClassWrapper )
+            {
+                ObjectClassImpl oc = ( ( ObjectClassWrapper ) obj ).getObjectClass();
+
+                if ( secondaryLabelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME )
+                {
+                    String[] names = oc.getNames();
+                    if ( ( names != null ) && ( names.length > 0 ) )
+                    {
+                        secondaryLabel = names[0];
+                    }
+                    else
+                    {
+                        secondaryLabel = NONE;
+                    }
+                }
+                else if ( secondaryLabelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES )
+                {
+                    String[] names = oc.getNames();
+                    if ( ( names != null ) && ( names.length > 0 ) )
+                    {
+                        secondaryLabel = ViewUtils.concateAliases( names );
+                    }
+                    else
+                    {
+                        secondaryLabel = NONE;
+                    }
+                }
+                else if ( secondaryLabelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_OID )
+                {
+                    secondaryLabel = oc.getOid();
+                }
+            }
+
+            if ( secondaryLabelAbbreviate && ( secondaryLabelAbbreviateMaxLength < secondaryLabel.length() ) )
+            {
+                secondaryLabel = secondaryLabel.substring( 0, secondaryLabelAbbreviateMaxLength ) + "..."; //$NON-NLS-1$
+            }
+
+            label += "   [" + secondaryLabel + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+        }
+
+        return label;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
+     */
+    public Image getImage( Object obj )
+    {
+        if ( obj instanceof AttributeTypeWrapper )
+        {
+            return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_ATTRIBUTE_TYPE )
+                .createImage();
+        }
+        else if ( obj instanceof ObjectClassWrapper )
+        {
+            return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_OBJECT_CLASS )
+                .createImage();
+        }
+
+        // Default
+        return PlatformUI.getWorkbench().getSharedImages().getImage( ISharedImages.IMG_OBJS_WARN_TSK );
+    }
+}