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

Examples of org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob


                }
                else
                {
                    entry.setChildrenFilter( newFilter.trim() );
                }
                new StudioBrowserJob( new InitializeChildrenRunnable( true, entry ) ).execute();
            }
        }
    }
View Full Code Here


    {
        if ( getSelectedEntries().length == 1 )
        {
            IEntry entry = getSelectedEntries()[0];
            entry.setChildrenFilter( null );
            new StudioBrowserJob( new InitializeChildrenRunnable( true, entry ) ).execute();
        }
    }
View Full Code Here

        boolean init = !isChecked();
        for ( IEntry entry : entries )
        {
            entry.setFetchReferrals( init );
        }
        new StudioBrowserJob( new InitializeChildrenRunnable( true, entries ) ).execute();
    }
View Full Code Here

        boolean init = !isChecked();
        for ( IEntry entry : entries )
        {
            entry.setFetchSubentries( init );
        }
        new StudioBrowserJob( new InitializeChildrenRunnable( true, entries ) ).execute();
    }
View Full Code Here

        boolean init = !isChecked();
        for ( IEntry entry : entries )
        {
            entry.setFetchAliases( init );
        }
        new StudioBrowserJob( new InitializeChildrenRunnable( true, entries ) ).execute();
    }
View Full Code Here

        boolean init = !isChecked();
        for ( IEntry entry : entries )
        {
            entry.setInitOperationalAttributes( init );
        }
        new StudioBrowserJob( new InitializeAttributesRunnable( entries ) ).execute();
    }
View Full Code Here

        // set new quick search
        conn.getSearchManager().setQuickSearch( quickSearch );

        // execute quick search
        new StudioBrowserJob( new SearchRunnable( new ISearch[]
            { quickSearch } ) ).execute();
    }
View Full Code Here

        {
            final IRootDSE rootDSE = ( IRootDSE ) parent;

            if ( !rootDSE.isChildrenInitialized() )
            {
                new StudioBrowserJob( new InitializeChildrenRunnable( false, rootDSE ) ).execute();
                return new String[]
                    { Messages.getString( "BrowserContentProvider.FetchingEntries" ) }; //$NON-NLS-1$
            }

            // get base entries
            List<IEntry> entryList = new ArrayList<IEntry>();
            entryList.addAll( Arrays.asList( rootDSE.getChildren() ) );

            // remove non-visible entries
            for ( Iterator<IEntry> it = entryList.iterator(); it.hasNext(); )
            {
                Object o = it.next();
                if ( !preferences.isShowDirectoryMetaEntries() && ( o instanceof DirectoryMetadataEntry ) )
                {
                    it.remove();
                }
            }

            return entryList.toArray();
        }
        else if ( parent instanceof IEntry )
        {
            final IEntry parentEntry = ( IEntry ) parent;

            if ( parentEntry instanceof IContinuation )
            {
                IContinuation continuation = ( IContinuation ) parentEntry;
                if ( continuation.getState() == State.UNRESOLVED )
                {
                    continuation.resolve();
                }
                if ( continuation.getState() == State.CANCELED )
                {
                    return new Object[0];
                }
            }

            if ( !parentEntry.isChildrenInitialized() )
            {
                new StudioBrowserJob( new InitializeChildrenRunnable( false, parentEntry ) ).execute();
                return new String[]
                    { Messages.getString( "BrowserContentProvider.FetchingEntries" ) }; //$NON-NLS-1$
            }
            else if ( parentEntry.getChildrenCount() <= preferences.getFoldingSize() || !preferences.isUseFolding() )
            {
                if ( entryToEntryPagesMap.containsKey( parentEntry ) )
                {
                    entryToEntryPagesMap.remove( parentEntry );
                }

                IEntry[] results = parentEntry.getChildren();

                List<Object> objects = new ArrayList<Object>();

                SearchManager sm = parentEntry.getBrowserConnection().getSearchManager();
                if ( sm != null && sm.getQuickSearch() != null
                    && parentEntry.getDn().equals( sm.getQuickSearch().getSearchBase() ) )
                {
                    objects.add( sm.getQuickSearch() );
                }

                if ( parentEntry.getTopPageChildrenRunnable() != null )
                {
                    objects.add( parentEntry.getTopPageChildrenRunnable() );
                }

                objects.addAll( Arrays.asList( results ) );

                if ( parentEntry.getNextPageChildrenRunnable() != null )
                {
                    objects.add( parentEntry.getNextPageChildrenRunnable() );
                }

                return objects.toArray();
            }
            else
            {
                BrowserEntryPage[] entryPages = getEntryPages( parentEntry );;
                return entryPages;
            }
        }
        else if ( parent instanceof BrowserSearchResultPage )
        {
            BrowserSearchResultPage srPage = ( BrowserSearchResultPage ) parent;
            Object[] objects = srPage.getChildren();
            if ( objects == null )
            {
                return new String[]
                    { Messages.getString( "BrowserContentProvider.FetchingSearchResults" ) }; //$NON-NLS-1$
            }
            else if ( objects instanceof ISearchResult[] )
            {
                ISearchResult[] srs = ( ISearchResult[] ) objects;
                return srs;
            }
            else
            {
                return objects;
            }
        }
        else if ( parent instanceof ISearch )
        {
            ISearch search = ( ISearch ) parent;
            if ( search instanceof IContinuation )
            {
                IContinuation continuation = ( IContinuation ) search;
                if ( continuation.getState() == State.UNRESOLVED )
                {
                    continuation.resolve();
                }
                if ( continuation.getState() == State.CANCELED )
                {
                    return new Object[0];
                }
            }

            if ( search.getSearchResults() == null || search.getSearchContinuations() == null )
            {
                new StudioBrowserJob( new SearchRunnable( new ISearch[]
                    { search } ) ).execute();
                return new String[]
                    { Messages.getString( "BrowserContentProvider.PerformingSearch" ) }; //$NON-NLS-1$
            }
            else if ( search.getSearchResults().length + search.getSearchContinuations().length == 0 )
            {
                return new String[]
                    { Messages.getString( "BrowserContentProvider.NoResults" ) }; //$NON-NLS-1$
            }
            else if ( search.getSearchResults().length <= preferences.getFoldingSize() || !preferences.isUseFolding() )
            {
                if ( searchToSearchResultPagesMap.containsKey( search ) )
                {
                    searchToSearchResultPagesMap.remove( search );
                }

                ISearchResult[] results = search.getSearchResults();
                SearchContinuation[] scs = search.getSearchContinuations();
                List<Object> objects = new ArrayList<Object>();

                if ( search.getTopSearchRunnable() != null )
                {
                    objects.add( search.getTopSearchRunnable() );
                }

                objects.addAll( Arrays.asList( results ) );

                if ( scs != null )
                {
                    objects.addAll( Arrays.asList( scs ) );
                }

                if ( search.getNextSearchRunnable() != null )
                {
                    objects.add( search.getNextSearchRunnable() );
                }

                return objects.toArray();
            }
            else
            {
                BrowserSearchResultPage[] srPages = getSearchResultPages( search );
                return srPages;
            }
        }
        else if ( parent instanceof BrowserCategory )
        {
            BrowserCategory category = ( BrowserCategory ) parent;
            IBrowserConnection browserConnection = category.getParent();

            switch ( category.getType() )
            {
                case BrowserCategory.TYPE_DIT:
                {
                    // open connection when expanding DIT
                    if ( browserConnection.getConnection() != null
                        && !browserConnection.getConnection().getJNDIConnectionWrapper().isConnected() )
                    {
                        new StudioBrowserJob( new OpenConnectionsRunnable( browserConnection.getConnection() ) )
                            .execute();
                        return new String[]
                            { Messages.getString( "BrowserContentProvider.OpeningConnection" ) }; //$NON-NLS-1$
                    }
View Full Code Here

        {
            final IRootDSE rootDSE = ( IRootDSE ) parent;

            if ( !rootDSE.isChildrenInitialized() && rootDSE.isDirectoryEntry() )
            {
                new StudioBrowserJob( new InitializeChildrenRunnable( new IEntry[]
                    { rootDSE } ) ).execute();
                return new String[]
                    { "Fetching Entries..." };
            }

            // get base entries
            List<IEntry> entryList = new ArrayList<IEntry>();
            entryList.addAll( Arrays.asList( rootDSE.getChildren() ) );

            // remove non-visible entries
            for ( Iterator<IEntry> it = entryList.iterator(); it.hasNext(); )
            {
                Object o = it.next();
                if ( !preferences.isShowDirectoryMetaEntries() && ( o instanceof DirectoryMetadataEntry ) )
                {
                    it.remove();
                }
            }

            return entryList.toArray();
        }
        else if ( parent instanceof IEntry )
            {
                final IEntry parentEntry = ( IEntry ) parent;

            if ( !parentEntry.isChildrenInitialized() && parentEntry.isDirectoryEntry() )
            {
                new StudioBrowserJob( new InitializeChildrenRunnable( new IEntry[]
                    { parentEntry } ) ).execute();
                return new String[]
                    { "Fetching Entries..." };
            }

            int childrenCount = parentEntry.getChildrenCount();
            if ( childrenCount <= preferences.getFoldingSize() || !preferences.isUseFolding() )
            {
                if ( entryToEntryPagesMap.containsKey( parentEntry ) )
                {
                    entryToEntryPagesMap.remove( parentEntry );
                }

                IEntry[] entries = parentEntry.getChildren();
                if ( entries == null )
                {
                    return new String[]
                        { "Fetching Entries..." };
                }
                else
                {
                    return entries;
                }
            }
            else
            {
                BrowserEntryPage[] entryPages = null;
                if ( !entryToEntryPagesMap.containsKey( parentEntry ) )
                {
                    entryPages = getEntryPages( parentEntry, 0, childrenCount - 1 );
                    entryToEntryPagesMap.put( parentEntry, entryPages );
                }
                else
                {
                    entryPages = entryToEntryPagesMap.get( parentEntry );
                    if ( childrenCount - 1 != entryPages[entryPages.length - 1].getLast() )
                    {
                        entryPages = getEntryPages( parentEntry, 0, childrenCount - 1 );
                        entryToEntryPagesMap.put( parentEntry, entryPages );
                    }
                }
                return entryPages;
            }
        }
        else if ( parent instanceof BrowserSearchResultPage )
        {
            BrowserSearchResultPage srPage = ( BrowserSearchResultPage ) parent;
            Object[] objects = srPage.getChildren();
            if ( objects == null )
            {
                return new String[]
                    { "Fetching Search Results..." };
            }
            else if ( objects instanceof ISearchResult[] )
            {
                ISearchResult[] srs = ( ISearchResult[] ) objects;
                return srs;
            }
            else
            {
                return objects;
            }
        }
        else if ( parent instanceof ISearch )
        {
            ISearch search = ( ISearch ) parent;
            if ( search.getSearchResults() == null )
            {
                new StudioBrowserJob( new SearchRunnable( new ISearch[]
                    { search } ) ).execute();
                return new String[]
                    { "Performing Search..." };
            }
            else if ( search.getSearchResults().length == 0 )
            {
                return new String[]
                    { "No Results" };
            }
            else if ( search.getSearchResults().length <= preferences.getFoldingSize() || !preferences.isUseFolding() )
            {
                ISearchResult[] results = search.getSearchResults();
                return results;
            }
            else
            {
                BrowserSearchResultPage[] srPages = null;
                if ( !searchToSearchResultPagesMap.containsKey( search ) )
                {
                    srPages = getSearchResultPages( search, 0, search.getSearchResults().length - 1 );
                    searchToSearchResultPagesMap.put( search, srPages );
                }
                else
                {
                    srPages = searchToSearchResultPagesMap.get( search );
                    if ( search.getSearchResults().length - 1 != srPages[srPages.length - 1].getLast() )
                    {
                        srPages = getSearchResultPages( search, 0, search.getSearchResults().length - 1 );
                        searchToSearchResultPagesMap.put( search, srPages );
                    }
                }
                return srPages;
            }
        }
        else if ( parent instanceof BrowserCategory )
        {
            BrowserCategory category = ( BrowserCategory ) parent;
            IBrowserConnection connection = category.getParent();

            switch ( category.getType() )
            {
                case BrowserCategory.TYPE_DIT:
                {
                    // open connection when expanding DIT
                    if ( !connection.getConnection().getJNDIConnectionWrapper().isConnected() )
                    {
                        new StudioBrowserJob( new OpenConnectionsRunnable( connection.getConnection() ) ).execute();
                        return new String[]
                            { "Opening Connection..." };
                    }

                    return new Object[]
View Full Code Here

            boolean ai = entry.isAttributesInitialized();
            if ( ( !ai || ( !oai && showOperationalAttributes && entry.isConsistent() ) ) && entry.isDirectoryEntry() )
            {
                InitializeAttributesRunnable runnable = new InitializeAttributesRunnable( new IEntry[]
                    { entry }, showOperationalAttributes );
                StudioBrowserJob job = new StudioBrowserJob( runnable );
                job.execute();
                return new Object[0];
            }
            else
            {
                IAttribute[] attributes = entry.getAttributes();
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob

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.