Package org.apache.directory.studio.connection.core

Examples of org.apache.directory.studio.connection.core.ConnectionFolder


     */
    public String getText( Object obj )
    {
        if ( obj instanceof ConnectionFolder )
        {
            ConnectionFolder folder = ( ConnectionFolder ) obj;
            return folder.getName();
        }
        if ( obj instanceof Connection )
        {
            Connection conn = ( Connection ) obj;
            if ( conn.getEncryptionMethod() == EncryptionMethod.LDAPS )
View Full Code Here


    public Object[] getElements( Object inputElement )
    {
        if ( inputElement != null && inputElement instanceof ConnectionFolderManager )
        {
            ConnectionFolderManager cfm = ( ConnectionFolderManager ) inputElement;
            ConnectionFolder rootConnectionFolder = cfm.getRootConnectionFolder();
            Object[] elements = getChildren( rootConnectionFolder );
            return elements;
        }
        else
        {
View Full Code Here

    {
        if ( parentElement != null && parentElement instanceof ConnectionFolder )
        {
            List<Object> children = new ArrayList<Object>();

            ConnectionFolder folder = ( ConnectionFolder ) parentElement;
            List<String> subFolderIds = folder.getSubFolderIds();
            List<String> connectionIds = folder.getConnectionIds();

            for ( String subFolderId : subFolderIds )
            {
                ConnectionFolder subFolder = ConnectionCorePlugin.getDefault().getConnectionFolderManager()
                    .getConnectionFolderById( subFolderId );
                if ( subFolder != null )
                {
                    children.add( subFolder );
                }
View Full Code Here

        Connection connection = new Connection( connectionParameter );
        connectionManager.addConnection( connection );

        ConnectionFolderManager connectionFolderManager = ConnectionCorePlugin.getDefault()
            .getConnectionFolderManager();
        ConnectionFolder rootConnectionFolder = connectionFolderManager.getRootConnectionFolder();
        rootConnectionFolder.addConnectionId( connection.getId() );

        selectConnection( name );
        StudioConnectionJob job = new StudioConnectionJob( new OpenConnectionsRunnable( connection ) );
        job.execute();
        job.join();
View Full Code Here

            PlatformUI.getWorkbench().getDisplay().getActiveShell(),
            Messages.getString( "NewConnectionFolderAction.NewConnectionFolder" ), Messages.getString( "NewConnectionFolderAction.NeterNameNewFolder" ), "", null ); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
        if ( dialog.open() == ConnectionFolderDialog.OK )
        {
            String name = dialog.getValue();
            ConnectionFolder folder = new ConnectionFolder( name );
            ConnectionCorePlugin.getDefault().getConnectionFolderManager().addConnectionFolder( folder );

            ConnectionFolder[] folders = getSelectedConnectionFolders();
            if ( folders != null && folders.length > 0 )
            {
                folders[0].addSubFolderId( folder.getId() );
            }
            else
            {
                ConnectionCorePlugin.getDefault().getConnectionFolderManager().getRootConnectionFolder()
                    .addSubFolderId( folder.getId() );
            }
        }

    }
View Full Code Here

     * @throws ConnectionIOException
     *      if an error occurs when converting values
     */
    private static ConnectionFolder readConnectionFolder( Element element ) throws ConnectionIOException
    {
        ConnectionFolder connectionFolder = new ConnectionFolder();

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

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

        // Connections
        Element connectionsElement = element.element( CONNECTIONS_TAG );
        if ( connectionsElement != null )
        {
            for ( Iterator<?> i = connectionsElement.elementIterator( CONNECTION_TAG ); i.hasNext(); )
            {
                Element connectionElement = ( Element ) i.next();

                Attribute connectionIdAttribute = connectionElement.attribute( ID_TAG );

                if ( connectionIdAttribute != null )
                {
                    connectionFolder.addConnectionId( connectionIdAttribute.getValue() );
                }
            }
        }

        // Sub-folders
        Element foldersElement = element.element( SUB_FOLDERS_TAG );
        if ( foldersElement != null )
        {
            for ( Iterator<?> i = foldersElement.elementIterator( SUB_FOLDER_TAG ); i.hasNext(); )
            {
                Element folderElement = ( Element ) i.next();
               
                Attribute folderIdAttribute = folderElement.attribute( ID_TAG );
               
                if ( folderIdAttribute != null )
                {
                    connectionFolder.addSubFolderId( folderIdAttribute.getValue() );
                }
            }
        }

        return connectionFolder;
View Full Code Here

                }
            }

            // Loading the ConnectionFolders
            ZipEntry connectionFoldersEntry = importFile.getEntry( "connectionFolders.xml" );
            ConnectionFolder rootConnectionFolder = null;
            if ( connectionFoldersEntry != null )
            {
                InputStream connectionFoldersInputStream = importFile.getInputStream( connectionFoldersEntry );
                ConnectionFolderManager connectionFolderManager = ConnectionCorePlugin.getDefault()
                    .getConnectionFolderManager();
                Set<ConnectionFolder> connectionFoldersSet = ConnectionIO
                    .loadConnectionFolders( connectionFoldersInputStream );
                for ( ConnectionFolder connectionFolder : connectionFoldersSet )
                {
                    if ( !"0".equals( connectionFolder.getId() ) )
                    {
                        connectionFolderManager.addConnectionFolder( connectionFolder );
                    }
                    else
                    {
                        rootConnectionFolder = connectionFolder;
                    }
                }

                // Root ConnectionFolder must be the last one to be loaded
                if ( rootConnectionFolder != null )
                {
                    ConnectionFolder realRootConnectionFolder = connectionFolderManager.getRootConnectionFolder();
                    // Adding subfolders
                    List<String> realSubFolderIds = realRootConnectionFolder.getSubFolderIds();
                    for ( String subFolderId : rootConnectionFolder.getSubFolderIds() )
                    {
                        if ( !realSubFolderIds.contains( subFolderId ) )
                        {
                            realRootConnectionFolder.addSubFolderId( subFolderId );
                        }
                    }

                    // Adding connections
                    List<String> realConnectionIds = realRootConnectionFolder.getConnectionIds();
                    for ( String connectionId : rootConnectionFolder.getConnectionIds() )
                    {
                        if ( !realConnectionIds.contains( connectionId ) )
                        {
                            realRootConnectionFolder.addConnectionId( connectionId );
                        }
                    }
                }
            }
View Full Code Here

                {
                    if ( event.item != null && event.item.getData() instanceof ConnectionFolder )
                    {
                        ConnectionFolderManager connectionFolderManager = ConnectionCorePlugin.getDefault()
                            .getConnectionFolderManager();
                        ConnectionFolder overFolder = ( ConnectionFolder ) event.item.getData();
                        Set<ConnectionFolder> allParentFolders = connectionFolderManager
                            .getAllParentFolders( overFolder );

                        if ( event.widget instanceof DropTarget )
                        {
                            DropTarget dropTarget = ( DropTarget ) event.widget;
                            if ( dropTarget.getControl() instanceof Tree )
                            {
                                Tree tree = ( Tree ) dropTarget.getControl();
                                TreeItem[] items = tree.getSelection();
                                for ( int i = 0; i < items.length; i++ )
                                {
                                    if ( items[i].getData() instanceof ConnectionFolder )
                                    {
                                        ConnectionFolder folder = ( ConnectionFolder ) items[i].getData();
                                        if ( allParentFolders.contains( folder ) )
                                        {
                                            isMoveConnectionFolderForbidden = true;
                                            break;
                                        }
View Full Code Here

                // get connection and folders to handle
                Object[] objects = ( Object[] ) event.data;
                Object target = event.item != null ? event.item.getData() : connectionFolderManager
                    .getRootConnectionFolder();

                ConnectionFolder targetFolder = null;
                if ( target instanceof ConnectionFolder )
                {
                    targetFolder = ( ConnectionFolder ) target;
                }
                else if ( target instanceof Connection )
                {
                    Connection connection = ( Connection ) target;
                    targetFolder = connectionFolderManager.getParentConnectionFolder( connection );
                }

                for ( Object object : objects )
                {
                    if ( object instanceof Connection )
                    {
                        Connection connection = ( Connection ) object;
                        if ( event.detail == DND.DROP_MOVE )
                        {
                            ConnectionFolder parentConnectionFolder = connectionFolderManager
                                .getParentConnectionFolder( connection );
                            parentConnectionFolder.removeConnectionId( connection.getId() );
                            targetFolder.addConnectionId( connection.getId() );
                        }
                        else if ( event.detail == DND.DROP_COPY )
                        {
                            Connection newConnection = ( Connection ) connection.clone();
                            connectionManager.addConnection( newConnection );
                            targetFolder.addConnectionId( newConnection.getId() );
                        }
                    }
                    else if ( object instanceof ConnectionFolder )
                    {
                        ConnectionFolder folder = ( ConnectionFolder ) object;
                        if ( event.detail == DND.DROP_MOVE )
                        {
                            ConnectionFolder parentConnectionFolder = connectionFolderManager
                                .getParentConnectionFolder( folder );
                            parentConnectionFolder.removeSubFolderId( folder.getId() );
                            targetFolder.addSubFolderId( folder.getId() );
                            // TODO: expand target folder
                        }
                        else if ( event.detail == DND.DROP_COPY )
                        {
                            ConnectionFolder newFolder = ( ConnectionFolder ) folder.clone();
                            connectionFolderManager.addConnectionFolder( newFolder );
                            targetFolder.addSubFolderId( newFolder.getId() );
                            // TODO: expand target folder
                        }
                    }
                }
            }
View Full Code Here

            .getConnectionFolderManager();
        ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();

        ConnectionFolder[] selectedFolders = getSelectedConnectionFolders();
        Connection[] selectedConnections = getSelectedConnections();
        ConnectionFolder targetFolder = null;
        if ( selectedFolders.length > 0 )
        {
            targetFolder = selectedFolders[0];
        }
        else if ( selectedConnections.length > 0 )
        {
            targetFolder = connectionFolderManager.getParentConnectionFolder( selectedConnections[0] );
        }
        if ( targetFolder == null )
        {
            targetFolder = connectionFolderManager.getRootConnectionFolder();
        }

        // connections
        List<Connection> connections = getConnectionsToPaste();
        for ( Connection connection : connections )
        {
            Connection newConnection = ( Connection ) connection.clone();
            connectionManager.addConnection( newConnection );
            targetFolder.addConnectionId( newConnection.getId() );
        }

        // connection folders
        List<ConnectionFolder> connectionFolders = getConnectionFoldersToPaste();
        for ( ConnectionFolder connectionFolder : connectionFolders )
        {
            ConnectionFolder newConnectionFolder = ( ConnectionFolder ) connectionFolder.clone();
            connectionFolderManager.addConnectionFolder( newConnectionFolder );
            targetFolder.addSubFolderId( newConnectionFolder.getId() );
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.connection.core.ConnectionFolder

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.