Package org.apache.directory.studio.ldapbrowser.core.model

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


            String dn = ""; //$NON-NLS-1$
            boolean enabled = true;

            if ( newInput != null && newInput instanceof IEntry )
            {
                IEntry entry = ( IEntry ) newInput;
                dn = Messages.getString( "EntryEditorWidgetContentProvider.DNLabel" ) + entry.getDn().getUpName(); //$NON-NLS-1$
            }
            else if ( newInput != null && newInput instanceof AttributeHierarchy )
            {
                AttributeHierarchy ah = ( AttributeHierarchy ) newInput;
                dn = Messages.getString( "EntryEditorWidgetContentProvider.DNLabel" ) + ah.getAttribute().getEntry().getDn().getUpName(); //$NON-NLS-1$
View Full Code Here


        boolean showOperationalAttributes = BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
            BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_SHOW_OPERATIONAL_ATTRIBUTES );

        if ( inputElement != null && inputElement instanceof IEntry )
        {
            IEntry entry = ( IEntry ) inputElement;

            if ( !entry.isAttributesInitialized() )
            {
                InitializeAttributesRunnable runnable = new InitializeAttributesRunnable( entry );
                StudioBrowserJob job = new StudioBrowserJob( runnable );
                job.execute();
                return new Object[0];
            }
            else
            {
                IAttribute[] attributes = entry.getAttributes();
                Object[] values = getValues( attributes, showOperationalAttributes );
                return values;
            }
        }
        else if ( inputElement != null && inputElement instanceof AttributeHierarchy )
View Full Code Here

        {
            // uncache old entry
            browserConnection.uncacheEntryRecursive( oldEntry );

            // remove old entry and add new entry to parent
            IEntry parent = oldEntry.getParententry();
            boolean hasMoreChildren = parent.hasMoreChildren();
            parent.deleteChild( oldEntry );

            List<StudioControl> controls = new ArrayList<StudioControl>();
            if ( oldEntry.isReferral() )
            {
                controls.add( StudioControl.MANAGEDSAIT_CONTROL );
            }

            // Here we try to read the renamed entry to be able to send the right event notification.
            // In some cases this don't work:
            // - if there was a referral and the entry was created on another (master) server and not yet sync'ed to the current server
            // So we use a dummy monitor to no bother the user with an error message.
            dummyMonitor.reset();
            newEntry = ReadEntryRunnable.getEntry( browserConnection, newDn, controls, dummyMonitor );
            dummyMonitor.done();
            if ( newEntry != null )
            {
                parent.addChild( newEntry );
            }
            parent.setHasMoreChildren( hasMoreChildren );

            // reset searches, if the renamed entry is a result of a search
            List<ISearch> searches = browserConnection.getSearchManager().getSearches();
            for ( ISearch search : searches )
            {
View Full Code Here

     */
    public int category( Object element )
    {
        if ( element instanceof IEntry )
        {
            IEntry entry = ( IEntry ) element;
            if ( ( entry instanceof DirectoryMetadataEntry || entry instanceof RootDSE || entry.isAlias() || entry
                .isReferral() )
                && preferences.isMetaEntriesLast() )
            {
                return 3;
            }
            else if ( entry.isSubentry() )
            {
                return 0;
            }
            else if ( !entry.hasChildren() && preferences.isLeafEntriesFirst() )
            {
                return 1;
            }
            else if ( entry.hasChildren() && preferences.isContainerEntriesFirst() )
            {
                return 1;
            }
            else
            {
View Full Code Here

                        return greaterThan();
                    }
                }
                else if ( lockedObject instanceof IEntry )
                {
                    IEntry entry = ( IEntry ) lockedObject;
                    if ( o1 == entry.getTopPageChildrenRunnable() )
                    {
                        return lessThan();
                    }
                    else if ( o1 == entry.getNextPageChildrenRunnable() )
                    {
                        return greaterThan();
                    }
                }
            }
            return lessThan();
        }
        if ( o2 instanceof StudioRunnableWithProgress )
        {
            StudioRunnableWithProgress runnable = ( StudioRunnableWithProgress ) o2;
            for ( Object lockedObject : runnable.getLockedObjects() )
            {
                if ( lockedObject instanceof ISearch )
                {
                    ISearch search = ( ISearch ) lockedObject;
                    if ( o2 == search.getTopSearchRunnable() )
                    {
                        return greaterThan();
                    }
                    else if ( o2 == search.getNextSearchRunnable() )
                    {
                        return lessThan();
                    }
                }
                else if ( lockedObject instanceof IEntry )
                {
                    IEntry entry = ( IEntry ) lockedObject;
                    if ( o2 == entry.getTopPageChildrenRunnable() )
                    {
                        return greaterThan();
                    }
                    else if ( o2 == entry.getNextPageChildrenRunnable() )
                    {
                        return lessThan();
                    }
                }
            }
            return greaterThan();
        }

        if ( o1 == null && o2 == null )
        {
            return equal();
        }
        else if ( o1 == null && o2 != null )
        {
            return lessThan();
        }
        else if ( o1 != null && o2 == null )
        {
            return greaterThan();
        }
        else if ( o1 instanceof IEntry || o2 instanceof IEntry )
        {
            if ( !( o1 instanceof IEntry ) && !( o2 instanceof IEntry ) )
            {
                return equal();
            }
            else if ( !( o1 instanceof IEntry ) && ( o2 instanceof IEntry ) )
            {
                return lessThan();
            }
            else if ( ( o1 instanceof IEntry ) && !( o2 instanceof IEntry ) )
            {
                return greaterThan();
            }
            else
            {
                IEntry entry1 = ( IEntry ) o1;
                IEntry entry2 = ( IEntry ) o2;

                int cat1 = category( entry1 );
                int cat2 = category( entry2 );
                if ( cat1 != cat2 )
                {
View Full Code Here

                        LdapURL searchContinuationUrl = sr.getSearchContinuationUrl();

                        if ( searchContinuationUrl == null )
                        {
                            LdapDN dn = JNDIUtils.getDn( sr );
                            IEntry entry = null;

                            Connection resultConnection = sr.getConnection();
                            IBrowserConnection resultBrowserConnection = BrowserCorePlugin.getDefault()
                                .getConnectionManager().getBrowserConnection( resultConnection );
                            if ( resultBrowserConnection == null )
View Full Code Here

     */
    private static IEntry createAndCacheEntry( IBrowserConnection browserConnection, LdapDN dn,
        StudioProgressMonitor monitor )
    {
        StudioProgressMonitor dummyMonitor = new StudioProgressMonitor( monitor );
        IEntry entry = null;

        // build tree to parent
        LinkedList<LdapDN> parentDnList = new LinkedList<LdapDN>();
        LdapDN parentDN = dn;
        while ( parentDN != null && browserConnection.getEntryFromCache( parentDN ) == null )
        {
            parentDnList.addFirst( parentDN );
            parentDN = DnUtils.getParent( parentDN );
        }

        for ( LdapDN aDN : parentDnList )
        {
            parentDN = DnUtils.getParent( aDN );
            if ( parentDN == null )
            {
                // only the root DSE has a null parent
                entry = browserConnection.getRootDSE();
            }
            else if ( !parentDN.isEmpty() && browserConnection.getEntryFromCache( parentDN ) != null )
            {
                // a normal entry has a parent but the parent isn't the rootDSE
                IEntry parentEntry = browserConnection.getEntryFromCache( parentDN );
                entry = new Entry( parentEntry, aDN.getRdn() );
                entry.setDirectoryEntry( true );
                parentEntry.addChild( entry );
                parentEntry.setChildrenInitialized( true );
                parentEntry.setHasMoreChildren( true );
                parentEntry.setHasChildrenHint( true );
                browserConnection.cacheEntry( entry );
            }
            else
            {
                // we have a base DN, check if the entry really exists in LDAP
View Full Code Here

     */
    public String getText( Object obj )
    {
        if ( obj instanceof IEntry )
        {
            IEntry entry = ( IEntry ) obj;

            StringBuffer append = new StringBuffer();

            if ( entry.isChildrenInitialized() && ( entry.getChildrenCount() > 0 ) || entry.getChildrenFilter() != null )
            {
                append.append( " (" ).append( entry.getChildrenCount() ); //$NON-NLS-1$
                if ( entry.hasMoreChildren() )
                {
                    append.append( "+" ); //$NON-NLS-1$
                }
                if ( entry.getChildrenFilter() != null )
                {
                    append.append( ", filtered" ); //$NON-NLS-1$
                }
                append.append( ")" ); //$NON-NLS-1$
            }

            if ( entry instanceof IRootDSE )
            {
                return "Root DSE" + append.toString(); //$NON-NLS-1$
            }
            else if ( entry instanceof IContinuation )
            {
                return entry.getUrl().toString() + append.toString();
            }
            else if ( entry instanceof BaseDNEntry )
            {
                return entry.getDn().getUpName() + append.toString();
            }
            else if ( entry.hasParententry() )
            {
                String label = ""; //$NON-NLS-1$
                if ( preferences.getEntryLabel() == BrowserCommonConstants.SHOW_DN )
                {
                    label = entry.getDn().getUpName();
                }
                else if ( preferences.getEntryLabel() == BrowserCommonConstants.SHOW_RDN )
                {
                    label = entry.getRdn().getUpName();
                }
                else if ( preferences.getEntryLabel() == BrowserCommonConstants.SHOW_RDN_VALUE )
                {
                    label = ( String ) entry.getRdn().getUpValue();
                }

                label += append.toString();

                if ( preferences.isEntryAbbreviate() && label.length() > preferences.getEntryAbbreviateMaxLength() )
                {
                    label = Utils.shorten( label, preferences.getEntryAbbreviateMaxLength() );
                }

                return label;
            }
            else
            {
                return entry.getDn().getUpName() + append.toString();
            }
        }
        else if ( obj instanceof SearchContinuation )
        {
            SearchContinuation sc = ( SearchContinuation ) obj;
            return sc.getUrl().toString();
        }
        else if ( obj instanceof BrowserEntryPage )
        {
            BrowserEntryPage container = ( BrowserEntryPage ) obj;
            return "[" + ( container.getFirst() + 1 ) + "..." + ( container.getLast() + 1 ) + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        }
        else if ( obj instanceof BrowserSearchResultPage )
        {
            BrowserSearchResultPage container = ( BrowserSearchResultPage ) obj;
            return "[" + ( container.getFirst() + 1 ) + "..." + ( container.getLast() + 1 ) + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        }
        else if ( obj instanceof ISearch )
        {
            ISearch search = ( ISearch ) obj;
            ISearchResult[] results = search.getSearchResults();
            SearchContinuation[] scs = search.getSearchContinuations();
            StringBuffer append = new StringBuffer( search.getName() );
            if ( results != null && scs != null )
            {
                append.append( " (" ).append( results.length + scs.length ); //$NON-NLS-1$
                if ( search.isCountLimitExceeded() )
                {
                    append.append( "+" ); //$NON-NLS-1$
                }
                append.append( ")" ); //$NON-NLS-1$
            }
            return append.toString();
        }
        else if ( obj instanceof IBookmark )
        {
            IBookmark bookmark = ( IBookmark ) obj;
            return bookmark.getName();
        }
        else if ( obj instanceof ISearchResult )
        {
            ISearchResult sr = ( ISearchResult ) obj;

            if ( sr.getEntry() instanceof IContinuation )
            {
                return sr.getEntry().getUrl().toString();
            }
            else if ( sr.getEntry().hasParententry() || sr.getEntry() instanceof IRootDSE )
            {
                String label = ""; //$NON-NLS-1$
                if ( sr.getEntry() instanceof IRootDSE )
                {
                    label = "Root DSE"; //$NON-NLS-1$
                }
                else if ( preferences.getSearchResultLabel() == BrowserCommonConstants.SHOW_DN )
                {
                    label = sr.getEntry().getDn().getUpName();
                }
                else if ( preferences.getSearchResultLabel() == BrowserCommonConstants.SHOW_RDN )
                {
                    label = sr.getEntry().getRdn().getUpName();
                }
                else if ( preferences.getSearchResultLabel() == BrowserCommonConstants.SHOW_RDN_VALUE )
                {
                    label = ( String ) sr.getEntry().getRdn().getUpValue();
                }

                if ( preferences.isSearchResultAbbreviate()
                    && label.length() > preferences.getSearchResultAbbreviateMaxLength() )
                {
                    label = Utils.shorten( label, preferences.getSearchResultAbbreviateMaxLength() );
                }

                return label;
            }
            else
            {
                return sr.getEntry().getDn().getUpName();
            }

        }
        else if ( obj instanceof StudioRunnableWithProgress )
        {
            StudioRunnableWithProgress runnable = ( StudioRunnableWithProgress ) obj;
            for ( Object lockedObject : runnable.getLockedObjects() )
            {
                if ( lockedObject instanceof ISearch )
                {
                    ISearch search = ( ISearch ) lockedObject;
                    if ( obj == search.getTopSearchRunnable() )
                    {
                        return Messages.getString( "BrowserLabelProvider.TopPage" ); //$NON-NLS-1$
                    }
                    else if ( obj == search.getNextSearchRunnable() )
                    {
                        return Messages.getString( "BrowserLabelProvider.NextPage" ); //$NON-NLS-1$
                    }
                }
                else if ( lockedObject instanceof IEntry )
                {
                    IEntry entry = ( IEntry ) lockedObject;
                    if ( obj == entry.getTopPageChildrenRunnable() )
                    {
                        return Messages.getString( "BrowserLabelProvider.TopPage" ); //$NON-NLS-1$
                    }
                    else if ( obj == entry.getNextPageChildrenRunnable() )
                    {
                        return Messages.getString( "BrowserLabelProvider.NextPage" ); //$NON-NLS-1$
                    }
                }
            }
View Full Code Here

     */
    public Image getImage( Object obj )
    {
        if ( obj instanceof IEntry )
        {
            IEntry entry = ( IEntry ) obj;
            if ( entry instanceof IRootDSE )
            {
                return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_ENTRY_ROOT );
            }
            else if ( entry instanceof DirectoryMetadataEntry && ( ( DirectoryMetadataEntry ) entry ).isSchemaEntry() )
            {
                return BrowserCommonActivator.getDefault().getImage(
                    BrowserCommonConstants.IMG_BROWSER_SCHEMABROWSEREDITOR );
            }
            else if ( entry.getDn().equals( entry.getBrowserConnection().getSchema().getDn() ) )
            {
                return BrowserCommonActivator.getDefault().getImage(
                    BrowserCommonConstants.IMG_BROWSER_SCHEMABROWSEREDITOR );
            }
            else
            {
                return BrowserLabelProvider.getImageByObjectClass( entry );
            }
        }
        else if ( obj instanceof BrowserEntryPage )
        {
            return PlatformUI.getWorkbench().getSharedImages().getImage( ISharedImages.IMG_OBJ_FOLDER );
        }
        else if ( obj instanceof BrowserSearchResultPage )
        {
            return PlatformUI.getWorkbench().getSharedImages().getImage( ISharedImages.IMG_OBJ_FOLDER );
        }
        else if ( obj instanceof IQuickSearch )
        {
            return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_QUICKSEARCH );
        }
        else if ( obj instanceof ISearch )
        {
            ISearch search = ( ISearch ) obj;
            if ( search instanceof IContinuation && ( ( IContinuation ) search ).getState() != State.RESOLVED )
            {
                return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_SEARCH_UNPERFORMED );
            }
            else if ( search.getSearchResults() != null )
            {
                return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_SEARCH );
            }
            else
            {
                return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_SEARCH_UNPERFORMED );
            }
        }
        else if ( obj instanceof IBookmark )
        {
            return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_BOOKMARK );
        }
        else if ( obj instanceof ISearchResult )
        {
            ISearchResult sr = ( ISearchResult ) obj;
            IEntry entry = sr.getEntry();
            return BrowserLabelProvider.getImageByObjectClass( entry );
        }
        else if ( obj instanceof StudioRunnableWithProgress )
        {
            StudioRunnableWithProgress runnable = ( StudioRunnableWithProgress ) obj;
            for ( Object lockedObject : runnable.getLockedObjects() )
            {
                if ( lockedObject instanceof ISearch )
                {
                    ISearch search = ( ISearch ) lockedObject;
                    if ( obj == search.getTopSearchRunnable() )
                    {
                        return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_TOP );
                    }
                    else if ( obj == search.getNextSearchRunnable() )
                    {
                        return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_NEXT );
                    }
                }
                else if ( lockedObject instanceof IEntry )
                {
                    IEntry entry = ( IEntry ) lockedObject;
                    if ( obj == entry.getTopPageChildrenRunnable() )
                    {
                        return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_TOP );
                    }
                    else if ( obj == entry.getNextPageChildrenRunnable() )
                    {
                        return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_NEXT );
                    }
                }
            }
View Full Code Here

        StudioProgressMonitor monitor )
    {
        try
        {
            // first check cache
            IEntry entry = browserConnection.getEntryFromCache( dn );
            if ( entry != null )
            {
                return entry;
            }
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.ldapbrowser.core.model.IEntry

Copyright © 2018 www.massapicom. 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.