KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > ui > views > connection > DragConnectionListener


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20
21 package org.apache.directory.ldapstudio.browser.ui.views.connection;
22
23
24 import java.util.ArrayList JavaDoc;
25 import java.util.List JavaDoc;
26
27 import org.apache.directory.ldapstudio.browser.common.dnd.ConnectionTransfer;
28 import org.apache.directory.ldapstudio.browser.core.model.IConnection;
29 import org.eclipse.swt.dnd.DND;
30 import org.eclipse.swt.dnd.DragSource;
31 import org.eclipse.swt.dnd.DragSourceEvent;
32 import org.eclipse.swt.dnd.DragSourceListener;
33 import org.eclipse.swt.widgets.Table;
34 import org.eclipse.swt.widgets.TableItem;
35
36
37 /**
38  * This class implements a {@link DragSourceListener} that is used to
39  * drag and drop connections withing the connections view.
40  *
41  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
42  * @version $Rev$, $Date$
43  */

44 public class DragConnectionListener implements DragSourceListener
45 {
46
47     /**
48      * Creates a new instance of DragConnectionListener.
49      */

50     public DragConnectionListener()
51     {
52     }
53
54
55     /**
56      * {@inheritDoc}
57      *
58      * This implementation does nothing.
59      */

60     public void dragStart( DragSourceEvent event )
61     {
62     }
63
64
65     /**
66      * {@inheritDoc}
67      *
68      * This implementation adds the dragged connections to the
69      * given event data.
70      */

71     public void dragSetData( DragSourceEvent event )
72     {
73         if ( ConnectionTransfer.getInstance().isSupportedType( event.dataType ) )
74         {
75             if ( event.widget instanceof DragSource )
76             {
77                 DragSource dragSource = ( DragSource ) event.widget;
78                 if ( dragSource.getControl() instanceof Table )
79                 {
80                     Table table = ( Table ) dragSource.getControl();
81                     TableItem[] items = table.getSelection();
82                     List JavaDoc<IConnection> connectionList = new ArrayList JavaDoc<IConnection>();
83                     for ( int i = 0; i < items.length; i++ )
84                     {
85                         if ( items[i].getData() instanceof IConnection )
86                         {
87                             connectionList.add( ( IConnection ) items[i].getData() );
88                         }
89                     }
90                     event.data = connectionList.toArray( new IConnection[connectionList.size()] );
91                 }
92             }
93         }
94     }
95
96
97     /**
98      * {@inheritDoc}
99      *
100      * This implementation does nothing.
101      */

102     public void dragFinished( DragSourceEvent event )
103     {
104         if ( event.detail == DND.DROP_MOVE && event.doit )
105         {
106             // this.connectionManager.removeConnection(this.dragConnection);
107
}
108     }
109
110 }
111
Popular Tags