directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r488371 [2/14] - in /directory/sandbox/pamarcelot/ldapstudio: ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/jobs/ ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/perspective/ ldapstudio-browser-ui...
Date Mon, 18 Dec 2006 17:57:49 GMT
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/InPlaceGeneralizedTimeValueProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/InPlaceGeneralizedTimeValueProvider.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/InPlaceGeneralizedTimeValueProvider.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/InPlaceGeneralizedTimeValueProvider.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,197 @@
+/*
+ *  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.ldapstudio.browser.ui.valueproviders;
+
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class InPlaceGeneralizedTimeValueProvider extends TextCellEditor implements ValueProvider, ModelModifier
+{
+
+    private TextValueProvider delegate;
+
+
+    public InPlaceGeneralizedTimeValueProvider( Composite parent )
+    {
+        super( parent );
+        this.delegate = new TextValueProvider( parent );
+    }
+
+
+    public void create( IEntry entry, String attributeDescription, Object newRawValue )
+        throws ModelModificationException
+    {
+        delegate.create( entry, attributeDescription, newRawValue );
+    }
+
+
+    public void delete( AttributeHierachie ah ) throws ModelModificationException
+    {
+        delegate.delete( ah );
+    }
+
+
+    public void delete( IValue oldValue ) throws ModelModificationException
+    {
+        delegate.delete( oldValue );
+    }
+
+
+    public String getDisplayValue( AttributeHierachie ah )
+    {
+        if ( ah == null )
+        {
+            return "NULL";
+        }
+        else if ( ah.size() == 1 && ah.getAttribute().getValueSize() == 1 )
+        {
+            return getDisplayValue( ah.getAttribute().getValues()[0] );
+        }
+        else
+        {
+            return "not displayable";
+        }
+    }
+
+
+    public String getDisplayValue( IValue value )
+    {
+        String displayValue = delegate.getDisplayValue( value );
+
+        if ( !BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+            BrowserUIConstants.PREFERENCE_SHOW_RAW_VALUES ) )
+        {
+
+            DateFormat ldapFormat = new SimpleDateFormat( "yyyyMMddHHmmssZ" );
+            DateFormat activeDirectoryFormat = new SimpleDateFormat( "yyyyMMddHHmmss'.'SSSZ" );
+            DateFormat targetFormat = DateFormat.getDateTimeInstance( DateFormat.MEDIUM, DateFormat.LONG );
+
+            String s = displayValue;
+            if ( s.matches( "[\\.0-9]+Z" ) )
+            {
+                s = s.replaceAll( "Z", "GMT" );
+            }
+
+            try
+            {
+                Date date = ldapFormat.parse( s );
+                displayValue = targetFormat.format( date ) + " (" + displayValue + ")";
+            }
+            catch ( ParseException e1 )
+            {
+                try
+                {
+                    Date date = activeDirectoryFormat.parse( s );
+                    displayValue = targetFormat.format( date ) + " (" + displayValue + ")";
+                }
+                catch ( ParseException e2 )
+                {
+                }
+            }
+        }
+
+        return displayValue;
+    }
+
+
+    public Object getEmptyRawValue( IEntry entry, String attributeDescription )
+    {
+        return delegate.getEmptyRawValue( entry, attributeDescription );
+    }
+
+
+    public Object getRawValue( AttributeHierachie ah )
+    {
+        return delegate.getRawValue( ah );
+    }
+
+
+    public Object getRawValue( IValue value )
+    {
+        return delegate.getRawValue( value );
+    }
+
+
+    public Object getRawValue( IConnection connection, Schema schema, Object value )
+    {
+        return delegate.getRawValue( connection, schema, value );
+    }
+
+
+    public void modify( IValue oldValue, Object newRawValue ) throws ModelModificationException
+    {
+        delegate.modify( oldValue, newRawValue );
+    }
+
+
+    public CellEditor getCellEditor()
+    {
+        return this;
+    }
+
+
+    public String getCellEditorName()
+    {
+        return "In-Place Generalized Time Editor";
+    }
+
+
+    public ImageDescriptor getCellEditorImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_INPLACE_GENERALIZEDTIMEEDITOR );
+    }
+
+
+    protected Object doGetValue()
+    {
+        return "".equals( text.getText() ) ? null : text.getText();
+    }
+
+
+    protected void doSetValue( Object value )
+    {
+        if ( value != null && value instanceof IValue.EmptyValue )
+        {
+            value = ( ( IValue.EmptyValue ) value ).getStringValue();
+        }
+        super.doSetValue( value );
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/InPlaceTextValueProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/InPlaceTextValueProvider.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/InPlaceTextValueProvider.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/InPlaceTextValueProvider.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,147 @@
+/*
+ *  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.ldapstudio.browser.ui.valueproviders;
+
+
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class InPlaceTextValueProvider extends TextCellEditor implements ValueProvider, ModelModifier
+{
+
+    private TextValueProvider delegate;
+
+
+    public InPlaceTextValueProvider( Composite parent )
+    {
+        super( parent );
+        this.delegate = new TextValueProvider( parent );
+    }
+
+
+    public void create( IEntry entry, String attributeDescription, Object newRawValue )
+        throws ModelModificationException
+    {
+        delegate.create( entry, attributeDescription, newRawValue );
+    }
+
+
+    public void delete( AttributeHierachie ah ) throws ModelModificationException
+    {
+        delegate.delete( ah );
+    }
+
+
+    public void delete( IValue oldValue ) throws ModelModificationException
+    {
+        delegate.delete( oldValue );
+    }
+
+
+    public String getDisplayValue( AttributeHierachie ah )
+    {
+        return delegate.getDisplayValue( ah );
+    }
+
+
+    public String getDisplayValue( IValue value )
+    {
+        return delegate.getDisplayValue( value );
+    }
+
+
+    public Object getEmptyRawValue( IEntry entry, String attributeDescription )
+    {
+        return delegate.getEmptyRawValue( entry, attributeDescription );
+    }
+
+
+    public Object getRawValue( AttributeHierachie ah )
+    {
+        return delegate.getRawValue( ah );
+    }
+
+
+    public Object getRawValue( IValue value )
+    {
+        return delegate.getRawValue( value );
+    }
+
+
+    public Object getRawValue( IConnection connection, Schema schema, Object value )
+    {
+        return delegate.getRawValue( connection, schema, value );
+    }
+
+
+    public void modify( IValue oldValue, Object newRawValue ) throws ModelModificationException
+    {
+        delegate.modify( oldValue, newRawValue );
+    }
+
+
+    public CellEditor getCellEditor()
+    {
+        return this;
+    }
+
+
+    public String getCellEditorName()
+    {
+        return "In-Place Text Editor";
+    }
+
+
+    public ImageDescriptor getCellEditorImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_INPLACE_TEXTEDITOR );
+    }
+
+
+    protected Object doGetValue()
+    {
+        return "".equals( text.getText() ) ? null : text.getText();
+    }
+
+
+    protected void doSetValue( Object value )
+    {
+        if ( value != null && value instanceof IValue.EmptyValue )
+        {
+            value = ( ( IValue.EmptyValue ) value ).getStringValue();
+        }
+        super.doSetValue( value );
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/MultivaluedValueProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/MultivaluedValueProvider.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/MultivaluedValueProvider.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/MultivaluedValueProvider.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,190 @@
+/*
+ *  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.ldapstudio.browser.ui.valueproviders;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.MultivaluedDialog;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+
+public class MultivaluedValueProvider extends CellEditor implements ValueProvider, ModelModifier
+{
+
+    protected Object value;
+
+    protected Composite parent;
+
+    protected ValueProviderManager valueProviderManager;
+
+
+    public MultivaluedValueProvider( Composite parent, ValueProviderManager valueProviderManager )
+    {
+        super( parent );
+        this.parent = parent;
+        this.valueProviderManager = valueProviderManager;
+    }
+
+
+    protected Control createControl( Composite parent )
+    {
+        return null;
+    }
+
+
+    protected Object doGetValue()
+    {
+        return this.value;
+    }
+
+
+    protected void doSetFocus()
+    {
+    }
+
+
+    protected void doSetValue( Object value )
+    {
+        this.value = value;
+    }
+
+
+    public void activate()
+    {
+        if ( this.getValue() != null && this.getValue() instanceof AttributeHierachie )
+        {
+            AttributeHierachie ah = ( AttributeHierachie ) this.getValue();
+            if ( ah != null )
+            {
+                MultivaluedDialog dialog = new MultivaluedDialog( this.parent.getShell(), ah );
+                dialog.open();
+            }
+        }
+
+        fireCancelEditor();
+    }
+
+
+    public CellEditor getCellEditor()
+    {
+        return this;
+    }
+
+
+    public String getCellEditorName()
+    {
+        return "Multivalued Editor";
+    }
+
+
+    public ImageDescriptor getCellEditorImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_MULTIVALUEDEDITOR );
+    }
+
+
+    public String getDisplayValue( AttributeHierachie ah )
+    {
+
+        List valueList = new ArrayList();
+        for ( Iterator it = ah.iterator(); it.hasNext(); )
+        {
+            IAttribute attribute = ( IAttribute ) it.next();
+            valueList.addAll( Arrays.asList( attribute.getValues() ) );
+        }
+
+        StringBuffer sb = new StringBuffer();
+        if ( valueList.size() > 1 )
+            sb.append( valueList.size() + " values: " );
+        for ( Iterator it = valueList.iterator(); it.hasNext(); )
+        {
+            IValue value = ( IValue ) it.next();
+            ValueProvider vp = this.valueProviderManager.getCurrentValueProvider( value );
+            sb.append( vp.getDisplayValue( value ) );
+            if ( it.hasNext() )
+                sb.append( ", " );
+        }
+        return sb.toString();
+    }
+
+
+    public String getDisplayValue( IValue value )
+    {
+        return "";
+    }
+
+
+    public Object getRawValue( AttributeHierachie ah )
+    {
+        return ah;
+    }
+
+
+    public Object getRawValue( IValue value )
+    {
+        return null;
+    }
+
+
+    public Object getRawValue( IConnection connection, Schema schema, Object value )
+    {
+        return null;
+    }
+
+
+    public void modify( IValue oldValue, Object newRawValue ) throws ModelModificationException
+    {
+    }
+
+
+    public void create( IEntry entry, String attributeName, Object newRawValue ) throws ModelModificationException
+    {
+    }
+
+
+    public void delete( AttributeHierachie ah ) throws ModelModificationException
+    {
+    }
+
+
+    public void delete( IValue oldValue ) throws ModelModificationException
+    {
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/ObjectClassValueProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/ObjectClassValueProvider.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/ObjectClassValueProvider.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/ObjectClassValueProvider.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,265 @@
+/*
+ *  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.ldapstudio.browser.ui.valueproviders;
+
+
+import java.util.Arrays;
+
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.internal.model.Attribute;
+import org.apache.directory.ldapstudio.browser.core.jobs.CreateValuesJob;
+import org.apache.directory.ldapstudio.browser.core.jobs.ModifyValueJob;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.core.model.schema.ObjectClassDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.ObjectClassDialog;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.TextDialog;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+
+public class ObjectClassValueProvider extends AbstractDialogCellEditor implements ValueProvider, ModelModifier
+{
+
+    public ObjectClassValueProvider( Composite parent )
+    {
+        super( parent );
+    }
+
+
+    public Object openDialogBox( Control cellEditorWindow )
+    {
+        Object value = getValue();
+        if ( value != null && value instanceof ObjectClassValueProviderRawValue )
+        {
+            ObjectClassValueProviderRawValue rawValue = ( ObjectClassValueProviderRawValue ) value;
+            ObjectClassDialog dialog = new ObjectClassDialog( cellEditorWindow.getShell(), rawValue.schema,
+                rawValue.value );
+            if ( dialog.open() == TextDialog.OK && !"".equals( dialog.getObjectClass() ) )
+            {
+                return dialog.getObjectClass();
+            }
+        }
+        return null;
+    }
+
+
+    public String getDisplayValue( AttributeHierachie ah )
+    {
+        if ( ah == null )
+        {
+            return "NULL";
+        }
+        else if ( ah.size() == 1 && ah.getAttribute().getValueSize() == 1 )
+        {
+            return getDisplayValue( ah.getAttribute().getValues()[0] );
+        }
+        else
+        {
+            return "not displayable";
+        }
+    }
+
+
+    public String getDisplayValue( IValue value )
+    {
+        if ( value == null )
+        {
+            return "NULL";
+        }
+        else if ( value.isString() )
+        {
+            String ocName = value.getStringValue();
+            if ( !BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+                BrowserUIConstants.PREFERENCE_SHOW_RAW_VALUES ) )
+            {
+                Schema schema = value.getAttribute().getEntry().getConnection().getSchema();
+                ObjectClassDescription ocd = schema.getObjectClassDescription( ocName );
+                if ( ocd.isStructural() )
+                {
+                    ocName = ocName + " (structural)";
+                }
+                else if ( ocd.isAbstract() )
+                {
+                    ocName = ocName + " (abstract)";
+                }
+                else if ( ocd.isAuxiliary() )
+                {
+                    ocName = ocName + " (auxiliary)";
+                }
+                else if ( ocd.isObsolete() )
+                {
+                    ocName = ocName + " (obsolete)";
+                }
+            }
+            return ocName;
+        }
+        else
+        {
+            return "BINARY";
+        }
+    }
+
+
+    public Object getEmptyRawValue( IEntry entry, String attributeName )
+    {
+        return null;
+    }
+
+
+    public Object getRawValue( AttributeHierachie ah )
+    {
+        return null;
+    }
+
+
+    public Object getRawValue( IValue value )
+    {
+        if ( value == null || !value.isString() || !value.getAttribute().isObjectClassAttribute() )
+        {
+            return null;
+        }
+        else
+        {
+            return getRawValue( value.getAttribute().getEntry().getConnection(), null, value.getStringValue() );
+        }
+    }
+
+
+    public Object getRawValue( IConnection connection, Schema schema, Object value )
+    {
+        if ( schema == null && connection != null )
+        {
+            schema = connection.getSchema();
+        }
+        if ( schema == null || value == null || !( value instanceof String ) )
+        {
+            return null;
+        }
+
+        String ocValue = ( String ) value;
+        ObjectClassValueProviderRawValue rawValue = new ObjectClassValueProviderRawValue( schema, ocValue );
+        return rawValue;
+    }
+
+
+    public void create( IEntry entry, String attributeName, Object newRawValue ) throws ModelModificationException
+    {
+    }
+
+
+    public void modify( IValue oldValue, Object newValue ) throws ModelModificationException
+    {
+
+        if ( oldValue.isString() && newValue instanceof String )
+        {
+
+            IEntry entry = oldValue.getAttribute().getEntry();
+            String[] allOcNames = entry.getConnection().getSchema().getObjectClassDescriptionNames();
+
+            if ( newValue != null && Arrays.asList( allOcNames ).contains( newValue ) )
+            {
+                String newObjectClassName = ( String ) newValue;
+                IAttribute attribute = oldValue.getAttribute();
+                if ( !oldValue.getStringValue().equals( newObjectClassName ) )
+                {
+                    if ( oldValue.isEmpty() )
+                    {
+                        attribute.deleteEmptyValue( this );
+                        new CreateValuesJob( attribute, newObjectClassName ).execute();
+                    }
+                    else
+                    {
+                        new ModifyValueJob( attribute, oldValue, newObjectClassName ).execute();
+                    }
+                }
+
+                if ( entry.getSubschema() != null )
+                {
+                    String[] must = entry.getSubschema().getMustAttributeNames();
+                    for ( int i = 0; i < must.length; i++ )
+                    {
+                        if ( entry.getAttribute( must[i] ) == null )
+                        {
+                            IAttribute att = new Attribute( entry, must[i] );
+                            entry.addAttribute( att, this );
+                            att.addEmptyValue( this );
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+
+    public void delete( AttributeHierachie ah ) throws ModelModificationException
+    {
+    }
+
+
+    public void delete( IValue oldValue ) throws ModelModificationException
+    {
+    }
+
+
+    public CellEditor getCellEditor()
+    {
+        return this;
+    }
+
+
+    public String getCellEditorName()
+    {
+        return "Object Class Editor";
+    }
+
+
+    public ImageDescriptor getCellEditorImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_INPLACE_OCEDITOR );
+    }
+
+    class ObjectClassValueProviderRawValue
+    {
+        Schema schema;
+
+        String value;
+
+
+        public ObjectClassValueProviderRawValue( Schema schema, String value )
+        {
+            super();
+            this.schema = schema;
+            this.value = value;
+        }
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/PasswordValueProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/PasswordValueProvider.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/PasswordValueProvider.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/PasswordValueProvider.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,205 @@
+/*
+ *  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.ldapstudio.browser.ui.valueproviders;
+
+
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.PasswordDialog;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.TextDialog;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+
+public class PasswordValueProvider extends AbstractDialogCellEditor implements ValueProvider, ModelModifier
+{
+
+    private IEntry entry;
+
+    private HexValueProvider delegate;
+
+
+    public PasswordValueProvider( Composite parent )
+    {
+        super( parent );
+        this.delegate = new HexValueProvider( parent );
+    }
+
+
+    public CellEditor getCellEditor()
+    {
+        return this;
+    }
+
+
+    public String getCellEditorName()
+    {
+        return "Password Editor";
+    }
+
+
+    public ImageDescriptor getCellEditorImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_PASSWORDEDITOR );
+    }
+
+
+    protected Object openDialogBox( Control cellEditorWindow )
+    {
+        Object value = getValue();
+        if ( value != null && value instanceof byte[] )
+        {
+            byte[] pw = ( byte[] ) value;
+            PasswordDialog dialog = new PasswordDialog( cellEditorWindow.getShell(), pw, entry );
+            if ( dialog.open() == TextDialog.OK )
+            {
+                return dialog.getNewPassword();
+            }
+        }
+        return null;
+    }
+
+
+    public String getDisplayValue( AttributeHierachie ah )
+    {
+        if ( ah == null )
+        {
+            return "NULL";
+        }
+        else if ( ah.size() == 1 && ah.getAttribute().getValueSize() == 1 )
+        {
+            return getDisplayValue( ah.getAttribute().getValues()[0] );
+        }
+        else
+        {
+            return "not displayable";
+        }
+    }
+
+
+    public String getDisplayValue( IValue value )
+    {
+
+        if ( BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+            BrowserUIConstants.PREFERENCE_SHOW_RAW_VALUES ) )
+        {
+            return delegate.getPlainTextValue( value );
+        }
+        else
+        {
+            if ( value == null )
+            {
+                return "NULL";
+            }
+
+            String password = value.getStringValue();;
+            if ( password == null )
+            {
+                return "NULL";
+            }
+            else
+            {
+                String text;
+                if ( "".equals( password ) )
+                {
+                    text = "Empty password";
+                }
+                else if ( password.indexOf( '{' ) == 0 && password.indexOf( '}' ) > 0 )
+                {
+                    String encryptionMethod = password.substring( password.indexOf( '{' ) + 1, password.indexOf( '}' ) );
+                    text = encryptionMethod + " encrypted password";
+                }
+                else
+                {
+                    text = "Plain text password";
+                }
+                return text;
+            }
+        }
+    }
+
+
+    public void create( IEntry entry, String attributeDescription, Object newRawValue )
+        throws ModelModificationException
+    {
+        delegate.create( entry, attributeDescription, newRawValue );
+    }
+
+
+    public void delete( AttributeHierachie ah ) throws ModelModificationException
+    {
+        delegate.delete( ah );
+    }
+
+
+    public void delete( IValue oldValue ) throws ModelModificationException
+    {
+        delegate.delete( oldValue );
+    }
+
+
+    public Object getEmptyRawValue( IEntry entry, String attributeDescription )
+    {
+        this.entry = entry;
+        return delegate.getEmptyRawValue( entry, attributeDescription );
+    }
+
+
+    public Object getRawValue( AttributeHierachie ah )
+    {
+        if ( ah != null )
+        {
+            this.entry = ah.getAttribute().getEntry();
+        }
+        return delegate.getRawValue( ah );
+    }
+
+
+    public Object getRawValue( IValue value )
+    {
+        this.entry = value.getAttribute().getEntry();
+        return delegate.getRawValue( value );
+    }
+
+
+    public Object getRawValue( IConnection connection, Schema schema, Object value )
+    {
+        this.entry = null;
+        return delegate.getRawValue( connection, schema, value );
+    }
+
+
+    public void modify( IValue oldValue, Object newRawValue ) throws ModelModificationException
+    {
+        delegate.modify( oldValue, newRawValue );
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/TextValueProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/TextValueProvider.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/TextValueProvider.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/TextValueProvider.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,308 @@
+/*
+ *  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.ldapstudio.browser.ui.valueproviders;
+
+
+import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.internal.model.Attribute;
+import org.apache.directory.ldapstudio.browser.core.jobs.CreateValuesJob;
+import org.apache.directory.ldapstudio.browser.core.jobs.DeleteAttributesValueJob;
+import org.apache.directory.ldapstudio.browser.core.jobs.ModifyValueJob;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+import org.apache.directory.ldapstudio.browser.core.utils.LdifUtils;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.TextDialog;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+
+public class TextValueProvider extends AbstractDialogCellEditor implements ValueProvider, ModelModifier
+{
+
+    public TextValueProvider( Composite parent )
+    {
+        super( parent );
+    }
+
+
+    public CellEditor getCellEditor()
+    {
+        return this;
+    }
+
+
+    public String getCellEditorName()
+    {
+        return "Text Editor";
+    }
+
+
+    public ImageDescriptor getCellEditorImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_TEXTEDITOR );
+    }
+
+
+    public Object openDialogBox( Control cellEditorWindow )
+    {
+        Object value = getValue();
+        if ( value != null && value instanceof String )
+        {
+            TextDialog dialog = new TextDialog( cellEditorWindow.getShell(), ( String ) value );
+            if ( dialog.open() == TextDialog.OK && !"".equals( dialog.getText() ) )
+            {
+                return dialog.getText();
+            }
+        }
+        return null;
+    }
+
+
+    public String getDisplayValue( AttributeHierachie ah )
+    {
+        Object obj = this.getRawValue( ah );
+        return obj == null ? "NULL" : obj.toString();
+    }
+
+
+    public String getDisplayValue( IValue value )
+    {
+        Object obj = this.getRawValue( value );
+        return obj == null ? "NULL" : obj.toString();
+    }
+
+
+    public Object getEmptyRawValue( IEntry entry, String attributeDescription )
+    {
+        if ( entry == null || attributeDescription == null )
+        {
+            return null;
+        }
+        if ( entry.getConnection().getSchema().getAttributeTypeDescription( attributeDescription )
+            .getSyntaxDescription().isString() )
+        {
+            return IValue.EMPTY_STRING_VALUE;
+        }
+        else
+        {
+            // return LdifUtils.utf8decode(IValue.EMPTY_BINARY_VALUE);
+            return IValue.EMPTY_BINARY_VALUE;
+        }
+    }
+
+
+    public Object getRawValue( AttributeHierachie ah )
+    {
+        if ( ah == null )
+        {
+            return null;
+        }
+        else if ( ah.size() == 1 && ah.getAttribute().getValueSize() == 0 )
+        {
+            return getEmptyRawValue( ah.getAttribute().getEntry(), ah.getAttribute().getDescription() );
+        }
+        else if ( ah.size() == 1 && ah.getAttribute().getValueSize() == 1 )
+        {
+            return getRawValue( ah.getAttribute().getValues()[0] );
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    public Object getRawValue( IValue value )
+    {
+        if ( value == null )
+        {
+            return null;
+        }
+        else if ( value.isString() )
+        {
+            return value.getStringValue();
+        }
+        else if ( value.isBinary() )
+        {
+            return isEditable( value.getBinaryValue() ) ? value.getStringValue() : null;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    public Object getRawValue( IConnection connection, Schema schema, Object value )
+    {
+        if ( value == null )
+        {
+            return null;
+        }
+        else if ( value instanceof String )
+        {
+            return value;
+        }
+        else if ( value instanceof byte[] )
+        {
+            String s = LdifUtils.utf8decode( ( byte[] ) value );
+            for ( int i = 0; i < s.length(); i++ )
+            {
+                if ( Character.isISOControl( s.charAt( i ) ) && s.charAt( i ) != '\n' && s.charAt( i ) != '\r' )
+                {
+                    return null;
+                }
+            }
+            return s;
+            // return isEditable((byte[])value) ?
+            // LdifUtils.utf8decode((byte[])this.value) : null;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    private boolean isEditable( byte[] b )
+    {
+
+        if ( b == null )
+        {
+            return false;
+        }
+
+        for ( int i = 0; i < b.length; i++ )
+        {
+            if ( !( b[i] == '\n' || b[i] == '\r' || ( b[i] >= '\u0020' && b[i] <= '\u007F' ) ) )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+
+    public void create( IEntry entry, String attributeDescription, Object newRawValue )
+        throws ModelModificationException
+    {
+        if ( entry != null && attributeDescription != null && newRawValue != null && newRawValue instanceof String )
+        {
+            if ( entry.getAttribute( attributeDescription ) != null )
+            {
+                this.modify( entry.getAttribute( attributeDescription ), newRawValue );
+            }
+            else
+            {
+                EventRegistry.suspendEventFireingInCurrentThread();
+                IAttribute attribute = new Attribute( entry, attributeDescription );
+                entry.addAttribute( attribute, this );
+                EventRegistry.resumeEventFireingInCurrentThread();
+
+                Object newValue;
+                if ( entry.getConnection().getSchema().getAttributeTypeDescription( attributeDescription )
+                    .getSyntaxDescription().isString() )
+                {
+                    newValue = ( String ) newRawValue;
+                }
+                else
+                {
+                    newValue = LdifUtils.utf8encode( ( String ) newRawValue );
+                }
+
+                new CreateValuesJob( attribute, newValue ).execute();
+            }
+        }
+    }
+
+
+    private void modify( IAttribute attribute, Object newRawValue ) throws ModelModificationException
+    {
+        if ( attribute != null && newRawValue != null && newRawValue instanceof String )
+        {
+            if ( attribute.getValueSize() == 0 )
+            {
+                String newValue = ( String ) newRawValue;
+                new CreateValuesJob( attribute, newValue ).execute();
+            }
+            else if ( attribute.getValueSize() == 1 )
+            {
+                this.modify( attribute.getValues()[0], newRawValue );
+            }
+        }
+    }
+
+
+    public void modify( IValue oldValue, Object newRawValue ) throws ModelModificationException
+    {
+        if ( oldValue != null && newRawValue != null && newRawValue instanceof String )
+        {
+
+            String newValue = ( String ) newRawValue;
+            IAttribute attribute = oldValue.getAttribute();
+            if ( !oldValue.getStringValue().equals( newValue ) )
+            {
+                if ( oldValue.isEmpty() )
+                {
+                    EventRegistry.suspendEventFireingInCurrentThread();
+                    attribute.deleteEmptyValue( this );
+                    EventRegistry.resumeEventFireingInCurrentThread();
+                    new CreateValuesJob( attribute, newValue ).execute();
+                }
+                else
+                {
+                    new ModifyValueJob( attribute, oldValue, newValue ).execute();
+                }
+            }
+        }
+    }
+
+
+    public void delete( AttributeHierachie ah ) throws ModelModificationException
+    {
+        if ( ah != null )
+        {
+            new DeleteAttributesValueJob( ah ).execute();
+        }
+    }
+
+
+    public void delete( IValue oldValue ) throws ModelModificationException
+    {
+        if ( oldValue != null )
+        {
+            new DeleteAttributesValueJob( oldValue ).execute();
+        }
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/ValueProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/ValueProvider.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/ValueProvider.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/ValueProvider.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,199 @@
+/*
+ *  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.ldapstudio.browser.ui.valueproviders;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CellEditor;
+
+
+public interface ValueProvider
+{
+
+    /**
+     * Returns the String displayed on the table.
+     * 
+     * @param attributes
+     * @return
+     */
+    public abstract String getDisplayValue( AttributeHierachie ah );
+
+
+    /**
+     * Returns the String displayed on the table.
+     * 
+     * @param value
+     * @return
+     */
+    public abstract String getDisplayValue( IValue value );
+
+
+    /**
+     * Returns the raw value or null if this value provider can't handle the
+     * given attributes.
+     * 
+     * The returned value must be editable with the cell editor returned by
+     * getCellEditor().
+     * 
+     * @param attributes
+     *                The attributes
+     * @return The raw value of the attriubtes or null
+     */
+    public abstract Object getRawValue( AttributeHierachie ah );
+
+
+    /**
+     * Returns the raw value or null if this value provider can't handle the
+     * given value.
+     * 
+     * The returned value must be editable with the cell editor returned by
+     * getCellEditor().
+     * 
+     * @param value
+     *                The value object
+     * @return The raw value of the value or null
+     */
+    public abstract Object getRawValue( IValue value );
+
+
+    /**
+     * Returns the raw value or null if this value provider can't handle the
+     * given value.
+     * 
+     * The returned value must be editable with the cell editor returned by
+     * getCellEditor().
+     * 
+     * @param schema
+     *                The connection used for context-dependent values, may
+     *                be null.
+     * @param schema
+     *                The schema used for context dependent-values, may be
+     *                null.
+     * @param value
+     *                The value of any type
+     * @return The raw value of the value or null
+     */
+    public abstract Object getRawValue( IConnection connection, Schema schema, Object value );
+
+
+    /**
+     * Creates the attribute with ghe given value at the entry.
+     * 
+     * It is called from a ICellModifier if no attribute of value exists and
+     * the raw value returned by the CellEditor isn't null.
+     * 
+     * @param entry
+     * @param attributeDescription
+     * @param newRawValue
+     * @throws ModelModificationException
+     */
+    public abstract void create( IEntry entry, String attributeDescription, Object newRawValue )
+        throws ModelModificationException;
+
+
+    /**
+     * Modifies the attribute and sets the given raw value
+     * 
+     * It is called from a ICellModfier if the attribute exists and the raw
+     * value returned by the CellEditor isn't null.
+     * 
+     * @param attribute
+     * @param newRawValue
+     * @throws ModelModificationException
+     */
+    // public abstract void modify(IAttribute[] attributes, Object
+    // newRawValue) throws ModelModificationException;
+    /**
+     * Modifies the value and sets the given raw value
+     * 
+     * It is called from a ICellModfier if the value exists and the raw
+     * value returned by the CellEditor isn't null.
+     * 
+     * @param value
+     * @param newRawValue
+     * @throws ModelModificationException
+     */
+    public abstract void modify( IValue value, Object newRawValue ) throws ModelModificationException;
+
+
+    /**
+     * Deletes the attributes
+     * 
+     * It is called from a ICellModfier if the attribute exists and the raw
+     * value returned by the CellEditor is null.
+     * 
+     * @param attributes
+     * @throws ModelModificationException
+     */
+    public abstract void delete( AttributeHierachie ah ) throws ModelModificationException;
+
+
+    /**
+     * Deletes the value
+     * 
+     * It is called from a ICellModfier if the value exists and the raw
+     * value returned by the CellEditor is null.
+     * 
+     * @param oldValue
+     * @throws ModelModificationException
+     */
+    public abstract void delete( IValue oldValue ) throws ModelModificationException;
+
+
+    /**
+     * Returns the CellEditor to handle the values
+     * 
+     * The input of the cell editor will be one of the objects return by
+     * getEmptyRawValue(IEntry, String), getRawValue(IAttribute) or
+     * getRawValue(IValue).
+     * 
+     * The output of the cell editor is the modified value or null.
+     * 
+     */
+    public abstract CellEditor getCellEditor();
+
+
+    /**
+     * Returns the editors name.
+     * 
+     * @return the editors name.
+     */
+    public abstract String getCellEditorName();
+
+
+    /**
+     * Returns the editors image.
+     * 
+     * @return the editors image.
+     */
+    public abstract ImageDescriptor getCellEditorImageDescriptor();
+
+
+    public abstract void dispose();
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/ValueProviderManager.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/ValueProviderManager.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/ValueProviderManager.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/valueproviders/ValueProviderManager.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,367 @@
+/*
+ *  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.ldapstudio.browser.ui.valueproviders;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.schema.AttributeTypeDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.LdapSyntaxDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+
+import org.eclipse.swt.widgets.Composite;
+
+
+public class ValueProviderManager
+{
+
+    private Composite parent;
+
+    private ValueProvider userSelectedValueProvider;
+
+    private MultivaluedValueProvider multiValuedValueProvider;
+
+    private InPlaceTextValueProvider defaultStringSingleLineValueProvider;
+
+    private TextValueProvider defaultStringMultiLineValueProvider;
+
+    private HexValueProvider defaultBinaryValueProvider;
+
+    private Map class2ValueProviderMap;
+
+
+    public ValueProviderManager( Composite parent )
+    {
+        this.parent = parent;
+
+        this.userSelectedValueProvider = null;
+        this.multiValuedValueProvider = new MultivaluedValueProvider( this.parent, this );
+        this.defaultStringSingleLineValueProvider = new InPlaceTextValueProvider( this.parent );
+        this.defaultStringMultiLineValueProvider = new TextValueProvider( this.parent );
+        this.defaultBinaryValueProvider = new HexValueProvider( this.parent );
+
+        this.class2ValueProviderMap = new HashMap();
+        ValueProvider[] valueProviders = getValueProviders( parent );
+        for ( int i = 0; i < valueProviders.length; i++ )
+        {
+            this.class2ValueProviderMap.put( valueProviders[i].getClass().getName(), valueProviders[i] );
+        }
+
+    }
+
+
+    public void dispose()
+    {
+        if ( this.parent != null )
+        {
+            this.userSelectedValueProvider = null;
+            this.multiValuedValueProvider.dispose();
+            this.defaultStringSingleLineValueProvider.dispose();
+            this.defaultStringMultiLineValueProvider.dispose();
+            this.defaultBinaryValueProvider.dispose();
+
+            for ( Iterator it = this.class2ValueProviderMap.values().iterator(); it.hasNext(); )
+            {
+                ValueProvider vp = ( ValueProvider ) it.next();
+                vp.dispose();
+            }
+
+            this.parent = null;
+        }
+    }
+
+
+    public void setUserSelectedValueProvider( ValueProvider userSelectedValueProvider )
+    {
+        this.userSelectedValueProvider = userSelectedValueProvider;
+    }
+
+
+    public ValueProvider getCurrentValueProvider( Schema schema, String attributeName )
+    {
+
+        // check attribute oid and names
+        AttributeTypeDescription atd = schema.getAttributeTypeDescription( attributeName );
+        Map attributeValueProviderMap = BrowserUIPlugin.getDefault().getUIPreferences().getAttributeValueProviderMap();
+        if ( atd.getNumericOID() != null && attributeValueProviderMap.containsKey( atd.getNumericOID().toLowerCase() ) )
+        {
+            return ( ValueProvider ) this.class2ValueProviderMap.get( attributeValueProviderMap.get( atd
+                .getNumericOID().toLowerCase() ) );
+        }
+        String[] names = atd.getNames();
+        for ( int i = 0; i < names.length; i++ )
+        {
+            if ( attributeValueProviderMap.containsKey( names[i].toLowerCase() ) )
+            {
+                return ( ValueProvider ) this.class2ValueProviderMap.get( attributeValueProviderMap.get( names[i]
+                    .toLowerCase() ) );
+            }
+        }
+
+        // check syntax
+        LdapSyntaxDescription lsd = atd.getSyntaxDescription();
+        if ( lsd != null )
+        {
+            Map syntaxValueProviderMap = BrowserUIPlugin.getDefault().getUIPreferences().getSyntaxValueProviderMap();
+            if ( lsd.getNumericOID() != null && syntaxValueProviderMap.containsKey( lsd.getNumericOID().toLowerCase() ) )
+            {
+                return ( ValueProvider ) this.class2ValueProviderMap.get( syntaxValueProviderMap.get( lsd
+                    .getNumericOID().toLowerCase() ) );
+            }
+            else if ( lsd.isBinary() )
+            {
+                return this.defaultBinaryValueProvider;
+            }
+            else if ( lsd.isString() )
+            {
+                return this.defaultStringSingleLineValueProvider;
+            }
+        }
+
+        // 
+        return null;
+
+    }
+
+
+    public ValueProvider getCurrentValueProvider( IEntry entry, String attributeName )
+    {
+
+        // check user-selected (forced) value provider
+        if ( this.userSelectedValueProvider != null )
+        {
+            return this.userSelectedValueProvider;
+        }
+
+        return getCurrentValueProvider( entry.getConnection().getSchema(), attributeName );
+
+    }
+
+
+    public ValueProvider getCurrentValueProvider( IValue value )
+    {
+
+        ValueProvider vp = this.getCurrentValueProvider( value.getAttribute().getEntry(), value.getAttribute()
+            .getDescription() );
+
+        if ( vp == this.defaultStringSingleLineValueProvider )
+        {
+            if ( value.getStringValue().indexOf( '\n' ) == -1 && value.getStringValue().indexOf( '\r' ) == -1 )
+            {
+                vp = this.defaultStringSingleLineValueProvider;
+            }
+            else
+            /*
+             * if(value.getStringValue().indexOf('\n')>-1 ||
+             * value.getStringValue().indexOf('\r')>-1)
+             */{
+                vp = this.defaultStringMultiLineValueProvider;
+            }
+        }
+
+        return vp;
+    }
+
+
+    public ValueProvider getCurrentValueProvider( AttributeHierachie ah )
+    {
+        if ( ah == null )
+        {
+            return null;
+        }
+        else if ( ah.size() == 1 && ah.getAttribute().getValueSize() == 0 )
+        {
+            return this.getCurrentValueProvider( ah.getAttribute().getEntry(), ah.getAttribute().getDescription() );
+        }
+        else if ( ah.size() == 1 && ah.getAttribute().getValueSize() == 1 )
+        {
+
+            if ( ah.getAttribute().isObjectClassAttribute() )
+            {
+                return this.multiValuedValueProvider;
+            }
+            if ( ah.getAttribute().getValues()[0].isRdnPart() )
+            {
+                return this.multiValuedValueProvider;
+            }
+
+            return this.getCurrentValueProvider( ah.getAttribute().getValues()[0] );
+        }
+        else
+        /* if(attribute.getValueSize() > 1) */{
+            return this.multiValuedValueProvider;
+        }
+    }
+
+
+    public ValueProvider[] getAlternativeValueProvider( IEntry entry, String attributeName )
+    {
+
+        Schema schema = entry.getConnection().getSchema();
+        return getAlternativeValueProvider( schema, attributeName );
+
+    }
+
+
+    public ValueProvider[] getAlternativeValueProvider( Schema schema, String attributeName )
+    {
+        List alternativeList = new ArrayList();
+
+        AttributeTypeDescription atd = schema.getAttributeTypeDescription( attributeName );
+
+        if ( atd.getSyntaxDescription().isBinary() )
+        {
+            alternativeList.add( this.defaultBinaryValueProvider );
+            alternativeList.add( this.defaultStringSingleLineValueProvider );
+            alternativeList.add( this.defaultStringMultiLineValueProvider );
+        }
+        else if ( atd.getSyntaxDescription().isString() )
+        {
+            alternativeList.add( this.defaultStringSingleLineValueProvider );
+            alternativeList.add( this.defaultStringMultiLineValueProvider );
+            alternativeList.add( this.defaultBinaryValueProvider );
+        }
+
+        alternativeList.add( this.multiValuedValueProvider );
+
+        alternativeList.remove( getCurrentValueProvider( schema, attributeName ) );
+
+        return ( ValueProvider[] ) alternativeList.toArray( new ValueProvider[alternativeList.size()] );
+    }
+
+
+    public ValueProvider[] getAlternativeValueProvider( IValue value )
+    {
+
+        List alternativeList = new ArrayList();
+
+        if ( value.isBinary() )
+        {
+            alternativeList.add( this.defaultBinaryValueProvider );
+            alternativeList.add( this.defaultStringSingleLineValueProvider );
+            alternativeList.add( this.defaultStringMultiLineValueProvider );
+        }
+        else if ( value.isString() )
+        {
+            alternativeList.add( this.defaultStringSingleLineValueProvider );
+            alternativeList.add( this.defaultStringMultiLineValueProvider );
+            alternativeList.add( this.defaultBinaryValueProvider );
+        }
+
+        alternativeList.add( this.multiValuedValueProvider );
+
+        alternativeList.remove( getCurrentValueProvider( value ) );
+
+        return ( ValueProvider[] ) alternativeList.toArray( new ValueProvider[alternativeList.size()] );
+    }
+
+
+    public ValueProvider[] getAlternativeValueProvider( AttributeHierachie ah )
+    {
+        if ( ah == null )
+        {
+            return new ValueProvider[0];
+        }
+        else if ( ah.size() == 1 && ah.getAttribute().getValueSize() == 0 )
+        {
+            return this.getAlternativeValueProvider( ah.getAttribute().getEntry(), ah.getAttribute().getDescription() );
+        }
+        else if ( ah.size() == 1 && ah.getAttribute().getValueSize() == 1 )
+        {
+
+            if ( ah.getAttribute().isObjectClassAttribute() )
+            {
+                return new ValueProvider[0];
+            }
+            if ( ah.getAttribute().getValues()[0].isRdnPart() )
+            {
+                return new ValueProvider[0];
+            }
+
+            return this.getAlternativeValueProvider( ah.getAttribute().getValues()[0] );
+        }
+        else
+        /* if(attribute.getValueSize() > 1) */{
+            return new ValueProvider[0];
+        }
+    }
+
+
+    public ValueProvider[] getAllValueProviders()
+    {
+        Set list = new LinkedHashSet();
+        list.add( this.defaultStringSingleLineValueProvider );
+        list.add( this.defaultStringMultiLineValueProvider );
+        list.add( defaultBinaryValueProvider );
+        list.addAll( this.class2ValueProviderMap.values() );
+        list.add( this.multiValuedValueProvider );
+        return ( ValueProvider[] ) list.toArray( new ValueProvider[list.size()] );
+    }
+
+
+    public ValueProvider getDefaultBinaryValueProvider()
+    {
+        return defaultBinaryValueProvider;
+    }
+
+
+    public ValueProvider getDefaultStringValueProvider()
+    {
+        return defaultStringSingleLineValueProvider;
+    }
+
+
+    public MultivaluedValueProvider getMultiValuedValueProvider()
+    {
+        return multiValuedValueProvider;
+    }
+
+
+    public static ValueProvider[] getValueProviders( Composite parent )
+    {
+        List vpList = new ArrayList();
+
+        vpList.add( new InPlaceTextValueProvider( parent ) );
+
+        vpList.add( new TextValueProvider( parent ) );
+        vpList.add( new AddressValueProvider( parent ) );
+        vpList.add( new HexValueProvider( parent ) );
+        vpList.add( new ImageValueProvider( parent ) );
+        vpList.add( new DnValueProvider( parent ) );
+        vpList.add( new PasswordValueProvider( parent ) );
+        vpList.add( new ObjectClassValueProvider( parent ) );
+        vpList.add( new InPlaceGeneralizedTimeValueProvider( parent ) );
+        // vpList.add(new InPlaceObjectClassValueProvider(parent));
+
+        return ( ValueProvider[] ) vpList.toArray( new ValueProvider[vpList.size()] );
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserView.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserView.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserView.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserView.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,295 @@
+/*
+ *  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.ldapstudio.browser.ui.views.browser;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.browser.BrowserConfiguration;
+import org.apache.directory.ldapstudio.browser.ui.widgets.browser.BrowserWidget;
+
+import org.eclipse.jface.viewers.StructuredSelection;
+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.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.IShowInTarget;
+import org.eclipse.ui.part.ShowInContext;
+import org.eclipse.ui.part.ViewPart;
+
+
+public class BrowserView extends ViewPart implements ModelModifier
+{
+
+    private BrowserConfiguration configuration;
+
+    private BrowserViewUniversalListener universalListener;
+
+    private BrowserViewActionGroup actionGroup;
+
+    private BrowserWidget mainWidget;
+
+
+    // private DragAction dragAction;
+    // private DropAction dropAction;
+
+    public static String getId()
+    {
+        return BrowserView.class.getName();
+    }
+
+
+    public BrowserView()
+    {
+        super();
+    }
+
+
+    public void setFocus()
+    {
+        mainWidget.getViewer().getControl().setFocus();
+    }
+
+
+    public void dispose()
+    {
+        if ( this.configuration != null )
+        {
+            this.actionGroup.dispose();
+            this.actionGroup = null;
+            this.universalListener.dispose();
+            this.universalListener = null;
+            this.configuration.dispose();
+            this.configuration = null;
+            this.mainWidget.dispose();
+            this.mainWidget = null;
+            getSite().setSelectionProvider( null );
+        }
+
+        super.dispose();
+    }
+
+
+    public void createPartControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+        GridLayout layout = new GridLayout();
+        layout.marginWidth = 0;
+        layout.marginHeight = 0;
+        composite.setLayout( layout );
+
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( composite,
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_browser_view" );
+
+        // create configuration
+        this.configuration = new BrowserConfiguration();
+
+        // create main widget
+        this.mainWidget = new BrowserWidget( this.configuration, getViewSite().getActionBars() );
+        this.mainWidget.createWidget( composite );
+        this.mainWidget.setInput( getSite() );
+
+        // create actions and context menu (and register global actions)
+        this.actionGroup = new BrowserViewActionGroup( this );
+        this.actionGroup.fillToolBar( this.mainWidget.getToolBarManager() );
+        this.actionGroup.fillMenu( this.mainWidget.getMenuManager() );
+        this.actionGroup.enableGlobalActionHandlers( getViewSite().getActionBars() );
+        this.actionGroup.fillContextMenu( this.mainWidget.getContextMenuManager() );
+
+        // create the listener
+        getSite().setSelectionProvider( this.mainWidget.getViewer() );
+        this.universalListener = new BrowserViewUniversalListener( this );
+
+        // DND support
+        // int ops = DND.DROP_COPY | DND.DROP_MOVE;
+        // viewer.addDragSupport(ops, new Transfer[]{TextTransfer.getInstance(),
+        // BrowserTransfer.getInstance()}, this.dragAction);
+        // viewer.addDropSupport(ops, new
+        // Transfer[]{BrowserTransfer.getInstance()}, this.dropAction);
+    }
+
+
+    public void select( Object obj )
+    {
+        if ( obj instanceof ISearchResult )
+        {
+            ISearchResult searchResult = ( ISearchResult ) obj;
+            ISearch search = searchResult.getSearch();
+
+            this.mainWidget.getViewer().expandToLevel( search, 1 );
+
+            this.mainWidget.getViewer().reveal( searchResult );
+            this.mainWidget.getViewer().refresh( searchResult, true );
+            this.mainWidget.getViewer().setSelection( new StructuredSelection( searchResult ), true );
+            this.mainWidget.getViewer().setSelection( new StructuredSelection( searchResult ), true );
+        }
+        if ( obj instanceof IEntry )
+        {
+            IEntry entry = ( IEntry ) obj;
+
+            List entryList = new ArrayList();
+            IEntry tempEntry = entry;
+            while ( tempEntry.getParententry() != null )
+            {
+                IEntry parentEntry = tempEntry.getParententry();
+                entryList.add( parentEntry );
+                tempEntry = parentEntry;
+            }
+
+            IEntry[] parentEntries = ( IEntry[] ) entryList.toArray( new IEntry[0] );
+            for ( int i = parentEntries.length - 1; i >= 0; i-- )
+            {
+
+                if ( !parentEntries[i].isChildrenInitialized() )
+                {
+                    parentEntries[i].setChildrenInitialized( true, this );
+                    parentEntries[i].setHasMoreChildren( true, this );
+                }
+            }
+
+            this.mainWidget.getViewer().reveal( entry );
+            this.mainWidget.getViewer().refresh( entry, true );
+            this.mainWidget.getViewer().setSelection( new StructuredSelection( entry ), true );
+            this.mainWidget.getViewer().setSelection( new StructuredSelection( entry ), true );
+        }
+    }
+
+
+    public static void setInput( IConnection connection )
+    {
+        try
+        {
+            String targetId = BrowserView.getId();
+            IViewPart targetView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(
+                targetId );
+
+            if ( targetView == null && connection != null )
+            {
+                try
+                {
+                    targetView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(
+                        targetId, null, IWorkbenchPage.VIEW_VISIBLE );
+                }
+                catch ( PartInitException e )
+                {
+                }
+            }
+
+            try
+            {
+                targetView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( targetId,
+                    null, IWorkbenchPage.VIEW_VISIBLE );
+            }
+            catch ( PartInitException e )
+            {
+            }
+
+            // set input
+            if ( targetView != null && targetView instanceof BrowserView )
+            {
+                ( ( BrowserView ) targetView ).universalListener.setInput( connection );
+            }
+        }
+        catch ( NullPointerException npe )
+        {
+        }
+    }
+
+
+    public Object getAdapter( Class required )
+    {
+
+        if ( IShowInTarget.class.equals( required ) )
+        {
+            return new IShowInTarget()
+            {
+                public boolean show( ShowInContext context )
+                {
+                    StructuredSelection selection = ( StructuredSelection ) context.getSelection();
+                    Object obj = selection.getFirstElement();
+                    if ( obj instanceof IValue )
+                    {
+                        IValue value = ( IValue ) obj;
+                        IEntry entry = value.getAttribute().getEntry();
+                        select( entry );
+                    }
+                    else if ( obj instanceof IAttribute )
+                    {
+                        IAttribute attribute = ( IAttribute ) obj;
+                        IEntry entry = attribute.getEntry();
+                        select( entry );
+
+                    }
+                    else if ( obj instanceof ISearchResult )
+                    {
+                        ISearchResult sr = ( ISearchResult ) obj;
+                        ISearch search = sr.getSearch();
+                        select( search );
+                    }
+                    System.out.println( "BrowserView: " + context.getInput() + "," + context.getSelection() );
+                    return true;
+                }
+            };
+        }
+
+        return null;
+    }
+
+
+    public BrowserViewActionGroup getActionGroup()
+    {
+        return actionGroup;
+    }
+
+
+    public BrowserConfiguration getConfiguration()
+    {
+        return configuration;
+    }
+
+
+    public BrowserWidget getMainWidget()
+    {
+        return mainWidget;
+    }
+
+
+    public BrowserViewUniversalListener getUniversalListener()
+    {
+        return universalListener;
+    }
+
+}



Mime
View raw message