Package org.apache.directory.studio.ldapservers.model

Examples of org.apache.directory.studio.ldapservers.model.LdapServer


            // Getting the selection
            StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
            if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
            {
                // Getting the server
                LdapServer server = ( LdapServer ) selection.getFirstElement();

                // Checking that the server is really an ApacheDS 1.5.4 server
                if ( !EXTENSION_ID.equalsIgnoreCase( server.getLdapServerAdapterExtension().getId() ) )
                {
                    String message = Messages.getString( "CreateConnectionAction.UnableReadServerConfiguration" ) //$NON-NLS-1$
                        + "\n\n" //$NON-NLS-1$
                        + Messages.getString( "CreateConnectionAction.NotA154Server" ); //$NON-NLS-1$
View Full Code Here


            // Getting the selection
            StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
            if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
            {
                // Getting the server
                LdapServer server = ( LdapServer ) selection.getFirstElement();

                // Checking that the server is really an ApacheDS 1.5.6 server
                if ( !EXTENSION_ID.equalsIgnoreCase( server.getLdapServerAdapterExtension().getId() ) )
                {
                    String message = Messages.getString( "CreateConnectionAction.UnableReadServerConfiguration" ) //$NON-NLS-1$
                        + "\n\n" //$NON-NLS-1$
                        + Messages.getString( "CreateConnectionAction.NotA156Server" ); //$NON-NLS-1$
View Full Code Here

     * @return
     *      the corresponding {@link LdapServer}
     */
    private static LdapServer readLdapServer( Element element )
    {
        LdapServer server = new LdapServer();

        // ID
        Attribute idAttribute = element.attribute( ID_ATTRIBUTE );
        if ( idAttribute != null )
        {
            server.setId( idAttribute.getValue() );
        }

        // Name
        Attribute nameAttribute = element.attribute( NAME_ATTRIBUTE );
        if ( nameAttribute != null )
        {
            server.setName( nameAttribute.getValue() );
        }

        // Adapter ID
        Attribute adapterIdAttribute = element.attribute( ADAPTER_ID_ATTRIBUTE );
        if ( adapterIdAttribute != null )
        {
            // Getting the id
            String adapterId = adapterIdAttribute.getValue();

            // Looking for the correct LDAP Server Adapter Extension object
            LdapServerAdapterExtension ldapServerAdapterExtension = LdapServerAdapterExtensionsManager.getDefault()
                .getLdapServerAdapterExtensionById( adapterId );
            if ( ldapServerAdapterExtension != null )
            {
                // The Adapter Extension has been found
                // Assigning it to the server
                server.setLdapServerAdapterExtension( ldapServerAdapterExtension );
            }
            else
            {
                // The Adapter Extension has not been found
                // Creating an "unknown" Adapter Extension
                UnknownLdapServerAdapterExtension unknownLdapServerAdapterExtension = new UnknownLdapServerAdapterExtension();

                // Adapter Id
                unknownLdapServerAdapterExtension.setId( adapterId );

                // Adapter Name
                Attribute adapterNameAttribute = element.attribute( ADAPTER_NAME_ATTRIBUTE );
                if ( adapterNameAttribute != null )
                {
                    unknownLdapServerAdapterExtension.setName( adapterNameAttribute.getValue() );
                }

                // Adapter Vendor
                Attribute adapterVendorAttribute = element.attribute( ADAPTER_VENDOR_ATTRIBUTE );
                if ( adapterVendorAttribute != null )
                {
                    unknownLdapServerAdapterExtension.setVendor( adapterVendorAttribute.getValue() );
                }

                // Adapter Version
                Attribute adapterVersionAttribute = element.attribute( ADAPTER_VERSION_ATTRIBUTE );
                if ( adapterVersionAttribute != null )
                {
                    unknownLdapServerAdapterExtension.setVersion( adapterVersionAttribute.getValue() );
                }

                // Assigning the "unknown" Adapter Extension to the server
                server.setLdapServerAdapterExtension( unknownLdapServerAdapterExtension );
            }
        }
        else
        {
            // TODO No Adapter ID, throw an error ?
View Full Code Here

        GridData gd = new GridData( SWT.FILL, SWT.NONE, true, false );
        gd.widthHint = 300;
        locationText.setLayoutData( gd );

        // Getting the server
        LdapServer server = ( LdapServer ) getElement();
        if ( server != null )
        {
            LdapServerAdapterExtension ldapServerAdapterExtension = server.getLdapServerAdapterExtension();

            nameText.setText( server.getName() );
            typeText.setText( ldapServerAdapterExtension.getName() + " " + ldapServerAdapterExtension.getVersion() ); //$NON-NLS-1$
            vendorText.setText( ldapServerAdapterExtension.getVendor() );
            locationText.setText( LdapServersManager.getServersFolder().append( server.getId() ).toOSString() );
        }

        return parent;
    }
View Full Code Here

                    return;
                }

                // Getting the kind of event and the associated server
                LdapServerEventType kind = event.getKind();
                LdapServer server = event.getServer();
                switch ( kind )
                {
                // The server status has changed
                    case STATUS_CHANGED:
                        // First, we refresh the server
                        refreshServer( server );

                        // Then, we get the status of the server to see if we
                        // need to start or stop the animation thread
                        LdapServerStatus state = server.getStatus();

                        // If the state is STARTING or STOPPING, we need to
                        // add the server to the list of servers needing
                        // animation and eventually start the animation thread
                        if ( ( state == LdapServerStatus.STARTING ) || ( state == LdapServerStatus.STOPPING ) )
                        {
                            boolean startAnimationThread = false;

                            synchronized ( serversNeedingAnimation )
                            {
                                if ( !serversNeedingAnimation.contains( server ) )
                                {
                                    if ( serversNeedingAnimation.isEmpty() )
                                        startAnimationThread = true;
                                    serversNeedingAnimation.add( server );
                                }
                            }

                            if ( startAnimationThread )
                            {
                                startAnimationThread();
                            }
                        }

                        // If the state is *not* STARTING or STOPPING, we need
                        // to remove the server from the list of servers
                        // needing animation and eventually stop the animation
                        // if this list is empty
                        else
                        {
                            boolean stopAnimationThread = false;

                            synchronized ( serversNeedingAnimation )
                            {
                                if ( serversNeedingAnimation.contains( server ) )
                                {
                                    serversNeedingAnimation.remove( server );
                                    if ( serversNeedingAnimation.isEmpty() )
                                        stopAnimationThread = true;
                                }
                            }

                            if ( stopAnimationThread )
                            {
                                stopAnimationThread();
                            }
                        }
                        break;
                    // The server has been renamed
                    case RENAMED:
                        // We simply refresh the server
                        refreshServer( server );
                        break;
                }

            }
        };

        // Adding the listener to the servers
        for ( LdapServer server : LdapServersManager.getDefault().getServersList() )
        {
            server.addListener( serverListener );
        }
    }
View Full Code Here

    {
        if ( view != null )
        {
            // Getting the selected server
            StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
            final LdapServer server = ( LdapServer ) selection.getFirstElement();

            if ( server != null )
            {
                IInputValidator validator = new IInputValidator()
                {
                    public String isValid( String newName )
                    {
                        if ( server.getName().equals( newName ) )
                        {
                            return null;
                        }
                        else if ( !LdapServersManager.getDefault().isNameAvailable( newName ) )
                        {
                            return Messages.getString( "RenameAction.ErrorNameInUse" ); //$NON-NLS-1$
                        }
                        else
                        {
                            return null;
                        }
                    }
                };

                // Opening a dialog to ask the user a new name for the server
                InputDialog dialog = new InputDialog( view.getSite().getShell(),
                    Messages.getString( "RenameAction.RenameServer" ), //$NON-NLS-1$
                    Messages.getString( "RenameAction.NewName" ), //$NON-NLS-1$
                    server.getName(), validator );
                dialog.open();

                String newName = dialog.getValue();
                if ( newName != null )
                {
                    server.setName( newName );
                }
            }
        }
    }
View Full Code Here

     */
    public String getColumnText( Object element, int columnIndex )
    {
        if ( element instanceof LdapServer )
        {
            LdapServer server = ( LdapServer ) element;
            if ( columnIndex == 0 )
            {
                return server.getName();
            }
            else if ( columnIndex == 1 )
            {
                LdapServerStatus status = ( ( LdapServer ) element ).getStatus();
                switch ( status )
View Full Code Here

        {
            // What we get from the TableViewer is a StructuredSelection
            StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();

            // Here's the real object
            LdapServer server = ( LdapServer ) selection.getFirstElement();

            // Asking for confirmation
            DeleteServerDialog dsd = new DeleteServerDialog( view.getSite().getShell(), server );
            if ( dsd.open() == DeleteServerDialog.OK )
            {
View Full Code Here

            // Getting the selection
            StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
            if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
            {
                // Getting the server
                LdapServer server = ( LdapServer ) selection.getFirstElement();

                // Creating and scheduling the job to start the server
                StudioLdapServerJob job = new StudioLdapServerJob( new OpenConfigurationLdapServerRunnable( server ) );
                job.schedule();
            }
View Full Code Here

            // Getting the selection
            StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
            if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
            {
                // Getting the server
                LdapServer server = ( LdapServer ) selection.getFirstElement();

                // Checking that the server is really an ApacheDS 1.5.7 server
                if ( !EXTENSION_ID.equalsIgnoreCase( server.getLdapServerAdapterExtension().getId() ) )
                {
                    String message = Messages.getString( "CreateConnectionAction.UnableReadServerConfiguration" ) //$NON-NLS-1$
                        + "\n\n" //$NON-NLS-1$
                        + Messages.getString( "CreateConnectionAction.NotA157Server" ); //$NON-NLS-1$
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.ldapservers.model.LdapServer

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.