Examples of IValue


Examples of org.apache.directory.studio.ldapbrowser.core.model.IValue

            element = ( ( Item ) element ).getData();
        }

        if ( newRawValue != null && element != null && element instanceof IValue && valueEditorManager != null )
        {
            IValue oldValue = ( IValue ) element;

            if ( EntryEditorWidgetTableMetadata.VALUE_COLUMN_NAME.equals( property ) )
            {
                new CompoundModification().modifyValue( oldValue, newRawValue );
            }
View Full Code Here

Examples of org.apache.directory.studio.ldapbrowser.core.model.IValue

    {
        boolean ok = true;

        if ( getSelectedValues().length == 1 && getSelectedAttributes().length == 0 )
        {
            IValue value = getSelectedValues()[0];
            StringBuffer message = new StringBuffer();

            if ( value.isEmpty() )
            {
                // validate single-valued attributes
                if ( value.getAttribute().getValueSize() > 1
                    && value.getAttribute().getAttributeTypeDescription().isSingleValued() )
                {
                    message.append( NLS.bind( Messages.getString( "OpenBestEditorAction.ValueSingleValued" ), //$NON-NLS-1$
                        value.getAttribute().getDescription() ) );
                    message.append( BrowserCoreConstants.LINE_SEPARATOR );
                    message.append( BrowserCoreConstants.LINE_SEPARATOR );
                }

                // validate if value is allowed
                IEntry entry = value.getAttribute().getEntry();
                Collection<AttributeTypeDescription> allAtds = SchemaUtils.getAllAttributeTypeDescriptions( entry );
                AttributeTypeDescription atd = value.getAttribute().getAttributeTypeDescription();
                if ( !allAtds.contains( atd ) )
                {
                    message.append( NLS.bind( Messages.getString( "OpenBestEditorAction.AttributeNotInSubSchema" ), //$NON-NLS-1$
                        value.getAttribute().getDescription() ) );
                    message.append( BrowserCoreConstants.LINE_SEPARATOR );
                    message.append( BrowserCoreConstants.LINE_SEPARATOR );
                }
            }

            // validate non-modifiable attributes
            if ( !SchemaUtils.isModifiable( value.getAttribute().getAttributeTypeDescription() ) )
            {
                message.append( NLS.bind( Messages.getString( "OpenBestEditorAction.ValueNotModifiable" ), //$NON-NLS-1$
                    value.getAttribute().getDescription() ) );
                message.append( BrowserCoreConstants.LINE_SEPARATOR );
                message.append( BrowserCoreConstants.LINE_SEPARATOR );
            }

            // validate modification of RDN
            if ( value.isRdnPart() && cellEditor != valueEditorManager.getRenameValueEditor() )
            {
                message.append( NLS.bind( Messages.getString( "OpenBestEditorAction.ValueIsRdnPart" ), //$NON-NLS-1$
                    value.getAttribute().getDescription() ) );
                message.append( BrowserCoreConstants.LINE_SEPARATOR );
                message.append( BrowserCoreConstants.LINE_SEPARATOR );
            }

            if ( message.length() > 0 )
            {
                if ( value.isEmpty() )
                {
                    message.append( Messages.getString( "OpenBestEditorAction.NewValueQuestion" ) ); //$NON-NLS-1$
                }
                else
                {
                    message.append( Messages.getString( "OpenBestEditorAction.EditValueQuestion" ) ); //$NON-NLS-1$
                }
                ok = MessageDialog.openConfirm( getShell(), getText(), message.toString() );
            }

            if ( ok )
            {
                super.run();
            }
            else
            {
                if ( value.isEmpty() )
                {
                    value.getAttribute().deleteEmptyValue();
                }
            }
        }
    }
View Full Code Here

Examples of org.apache.directory.studio.ldapbrowser.core.model.IValue

     */
    public final String getColumnText( Object obj, int index )
    {
        if ( obj != null && obj instanceof IValue )
        {
            IValue value = ( IValue ) obj;
            switch ( index )
            {
                case EntryEditorWidgetTableMetadata.KEY_COLUMN_INDEX:
                    return value.getAttribute().getDescription();
                case EntryEditorWidgetTableMetadata.VALUE_COLUMN_INDEX:
                    IValueEditor vp = this.valueEditorManager.getCurrentValueEditor( value );
                    String dv = vp.getDisplayValue( value );
                    return dv;
                default:
View Full Code Here

Examples of org.apache.directory.studio.ldapbrowser.core.model.IValue

     * {@inheritDoc}
     */
    public Font getFont( Object element )
    {
        IAttribute attribute = null;
        IValue value = null;
        if ( element instanceof IAttribute )
        {
            attribute = ( IAttribute ) element;
        }
        else if ( element instanceof IValue )
        {
            value = ( IValue ) element;
            attribute = value.getAttribute();
        }

        // inconsistent attributes and values
        if ( value != null )
        {
            if ( value.isEmpty() )
            {
                FontData[] fontData = Display.getDefault().getSystemFont().getFontData();
                FontData fontDataBoldItalic = new FontData( fontData[0].getName(), fontData[0].getHeight(), SWT.BOLD
                    | SWT.ITALIC );
                return BrowserCommonActivator.getDefault().getFont( new FontData[]
View Full Code Here

Examples of org.apache.directory.studio.ldapbrowser.core.model.IValue

     * {@inheritDoc}
     */
    public Color getForeground( Object element )
    {
        IAttribute attribute = null;
        IValue value = null;
        if ( element instanceof IAttribute )
        {
            attribute = ( IAttribute ) element;
        }
        else if ( element instanceof IValue )
        {
            value = ( IValue ) element;
            attribute = value.getAttribute();
        }

        // inconsistent attributes and values
        if ( value != null )
        {
            if ( value.isEmpty() )
            {
                return BrowserCommonActivator.getDefault().getColor(
                    Display.getDefault().getSystemColor( SWT.COLOR_RED ).getRGB() );
            }
        }
View Full Code Here

Examples of org.apache.directory.studio.ldapbrowser.core.model.IValue

        {
            String description = attributes[i].getDescription();
            IValue[] values = attributes[i].getValues();
            for ( int ii = 0; ii < values.length; ii++ )
            {
                IValue value = values[ii];
                Object rawValue = value.getRawValue();
                if ( jndiAttributes.get( description ) != null )
                {
                    jndiAttributes.get( description ).add( rawValue );
                }
                else
View Full Code Here

Examples of org.apache.directory.studio.ldapbrowser.core.model.IValue

        // check argument
        if ( o == null || !( o instanceof IValue ) )
        {
            return false;
        }
        IValue vc = ( IValue ) o;

        // compare attributes
        if ( !vc.getAttribute().equals( this.getAttribute() ) )
        {
            return false;
        }

        // compare values
        if ( this.isEmpty() && vc.isEmpty() )
        {
            return true;
        }
        else if ( this.isBinary() && vc.isBinary() )
        {
            return Utils.equals( this.getBinaryValue(), vc.getBinaryValue() );
        }
        else if ( this.isString() && vc.isString() )
        {
            return ( this.getStringValue().equals( vc.getStringValue() ) );
        }
        else
        {
            return false;
        }
View Full Code Here

Examples of org.apache.directory.studio.ldapbrowser.core.model.IValue

        Set<IValue> valueSet = getValueSet();
        if ( !valueSet.isEmpty() )
        {
            for ( Iterator<IValue> iterator = valueSet.iterator(); iterator.hasNext(); )
            {
                IValue value = iterator.next();
                switch ( mode )
                {
                    case UTF8:
                        text.append( LdifUtils.utf8decode( value.getBinaryValue() ) );
                        if ( iterator.hasNext() )
                        {
                            text.append( BrowserCoreConstants.LINE_SEPARATOR );
                        }
                        break;
                    case BASE64:
                        text.append( LdifUtils.base64encode( value.getBinaryValue() ) );
                        if ( iterator.hasNext() )
                        {
                            text.append( BrowserCoreConstants.LINE_SEPARATOR );
                        }
                        break;
                    case HEX:
                        text.append( LdifUtils.hexEncode( value.getBinaryValue() ) );
                        if ( iterator.hasNext() )
                        {
                            text.append( BrowserCoreConstants.LINE_SEPARATOR );
                        }
                        break;
View Full Code Here

Examples of org.apache.directory.studio.ldapbrowser.core.model.IValue

            && getSelectedAttributeHierarchies()[0].getAttribute().getValueSize() == 1
            && getSelectedSearchResults().length == 1 )
        {
            try
            {
                IValue value = getSelectedAttributeHierarchies()[0].getAttribute().getValues()[0];
                if ( value.isString() && LdapDN.isValid( value.getStringValue() ) )
                {
                    return new ConnectionAndDn( value.getAttribute().getEntry().getBrowserConnection(), new LdapDN(
                        value.getStringValue() ) );
                }
            }
            catch ( InvalidNameException e )
            {
                // no valid DN
            }
        }

        if ( getSelectedValues().length == 1 && getSelectedAttributes().length == 0 )
        {
            try
            {
                IValue value = getSelectedValues()[0];
                if ( value.isString() && LdapDN.isValid( value.getStringValue() ) )
                {
                    return new ConnectionAndDn( value.getAttribute().getEntry().getBrowserConnection(), new LdapDN(
                        value.getStringValue() ) );
                }
            }
            catch ( InvalidNameException e )
            {
                // no valid DN
View Full Code Here

Examples of org.apache.directory.studio.ldapbrowser.core.model.IValue

    /**
     * {@inheritDoc}
     */
    protected Control createContents( Composite parent )
    {
        IValue value = getValue( getElement() );

        Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
        Composite mainGroup = BaseWidgetUtils.createColumnContainer( composite, 2, 1 );

        BaseWidgetUtils.createLabel( mainGroup, Messages.getString( "ValuePropertyPage.AttributeDescription" ), 1 ); //$NON-NLS-1$
        descriptionText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 ); //$NON-NLS-1$

        BaseWidgetUtils.createLabel( mainGroup, Messages.getString( "ValuePropertyPage.ValueType" ), 1 ); //$NON-NLS-1$
        typeText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 ); //$NON-NLS-1$

        BaseWidgetUtils.createLabel( mainGroup, Messages.getString( "ValuePropertyPage.ValueSize" ), 1 ); //$NON-NLS-1$
        sizeText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 ); //$NON-NLS-1$

        BaseWidgetUtils.createLabel( mainGroup, Messages.getString( "ValuePropertyPage.Data" ), 1 ); //$NON-NLS-1$
        if ( value != null && value.isString() )
        {
            valueText = new Text( mainGroup, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY );
            valueText.setFont( JFaceResources.getFont( JFaceResources.TEXT_FONT ) );
            GridData gd = new GridData( GridData.FILL_BOTH );
            gd.widthHint = convertHorizontalDLUsToPixels( ( int ) ( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2 ) );
            gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 4 );
            valueText.setLayoutData( gd );
            valueText.setBackground( parent.getBackground() );
        }
        else
        {
            valueText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 ); //$NON-NLS-1$
        }

        if ( value != null )
        {
            super.setMessage( Messages.getString( "ValuePropertyPage.Value" ) //$NON-NLS-1$
                + org.apache.directory.studio.connection.core.Utils.shorten( value.toString(), 30 ) );

            descriptionText.setText( value.getAttribute().getDescription() );
            // valueText.setText(LdifUtils.mustEncode(value.getBinaryValue())?"Binary":value.getStringValue());
            valueText.setText( value.isString() ? value.getStringValue() : Messages
                .getString( "ValuePropertyPage.Binary" ) ); //$NON-NLS-1$
            typeText
                .setText( value.isString() ? Messages.getString( "ValuePropertyPage.String" ) : Messages.getString( "ValuePropertyPage.Binary" ) ); //$NON-NLS-1$ //$NON-NLS-2$

            int bytes = value.getBinaryValue().length;
            int chars = value.isString() ? value.getStringValue().length() : 0;
            String size = value.isString() ? chars
                + ( chars > 1 ? Messages.getString( "ValuePropertyPage.Characters" ) : Messages.getString( "ValuePropertyPage.Character" ) ) : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            size += Utils.formatBytes( bytes );
            sizeText.setText( size );
        }

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.