Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » DND within TableTree?
DND within TableTree? [message #449338] Fri, 21 January 2005 22:57 Go to next message
Eclipse UserFriend
Originally posted by: fn2o-mycl.spamex.com

This is a multi-part message in MIME format.

------=_NextPart_000_0006_01C4FFC9.898BDAD0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

When I converted my TreeViewer to a TableTreeViewer, the drag-and-drop =
support broke. Performing a selection and drag gesture no longer =
initiates a drag operation. The dragStart() method is never evoked. Are =
there any known issues that prevent dragging and dropping within the =
TableTree? Do I need to supply a special TableTreeViewer SWT style to =
enable dragging? Please help.



Thanks,
Mark

reply to: fn2o-mycl@spamex.com

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
tableTreeViewer =3D new TableTreeViewer(parent, SWT.FULL_SELECTION + =
SWT.MULTI);

tableTreeViewer.setContentProvider( new DomainContentProvider () );

labelProvider =3D new DomainLabelProvider ();

tableTreeViewer.setLabelProvider(labelProvider);

tableTreeViewer.setUseHashlookup(true);

=20

tableTreeViewer.setInput (getInitalInput());

=20

Table table =3D tableTreeViewer.getTableTree().getTable();

new TableColumn(table, SWT.LEFT).setText(DomainConstants.COLUMN_NAME);

new TableColumn(table, SWT.LEFT).setText(DomainConstants.COLUMN_TYPE);

new TableColumn(table, =
SWT.RIGHT).setText(DomainConstants.COLUMN_STATUS);

new TableColumn(table, =
SWT.RIGHT).setText(DomainConstants.COLUMN_PRIORITY);

=20

// Add drag and drop support.

=20

int ops =3D DND.DROP_COPY | DND.DROP_MOVE;

=20

Transfer[] transfers =3D new Transfer[] { =
DomainSymbolTransfer.getInstance()};

tableTreeViewer.addDragSupport(ops, transfers, new =
SymbolDragListener(tableTreeViewer));

=20

dropAdapter =3D new TableTreeDropAdapter(tableTreeViewer);

tableTreeViewer.addDropSupport(ops, transfers, dropAdapter);

------=_NextPart_000_0006_01C4FFC9.898BDAD0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2523" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">When I converted my =
TreeViewer to a=20
TableTreeViewer, the drag-and-drop support broke. Performing a selection =
and=20
drag gesture no longer&nbsp;initiates a&nbsp;drag operation.=20
The&nbsp;dragStart() method is never evoked.&nbsp; Are there any known =
issues=20
that prevent dragging and dropping within the TableTree?&nbsp; Do I need =
to=20
supply a special TableTreeViewer SWT style to enable dragging?&nbsp; =
Please=20
help.</SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN><?xml:namespace =
prefix =3D o ns=20
=3D "urn:schemas-microsoft-com:office:office" =
/><o:p></o:p>&nbsp;</P></FONT><FONT=20
face=3DArial size=3D2></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Mark</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>reply to: <A=20
href=3D"mailto:fn2o-mycl@spamex.com">fn2o-mycl@spamex.com</A></FONT></DIV=
>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</FONT></DIV>
<DIV>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0>tableTreeViewer =3D new =
TableTreeViewer(parent,=20
SWT.FULL_SELECTION + SWT.MULTI);<o:p></o:p></FONT></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0>tableTreeViewer.setContentProvider( =
new=20
DomainContentProvider () );<o:p></o:p></FONT></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0>labelProvider =3D new =
DomainLabelProvider=20
();<o:p></o:p></FONT></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT=20
color=3D#0000a0>tableTreeViewer.setLabelProvider(labelProvider); <o:p></o:=
p></FONT></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT=20
color=3D#0000a0>tableTreeViewer.setUseHashlookup(true);<o:p ></o:p></FONT>=
</FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0><SPAN=20
style=3D"mso-tab-count: =
2"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
</SPAN><o:p></o:p></FONT></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0>tableTreeViewer.setInput=20
(getInitalInput());<o:p></o:p></FONT></FONT></FONT></P >
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0><SPAN=20
style=3D"mso-spacerun: yes"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
</SPAN><o:p></o:p></FONT></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0>Table table =3D=20
tableTreeViewer.getTableTree().getTable();<o:p></o:p></FONT ></FONT></FONT=
></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0>new TableColumn(table,=20
SWT.LEFT).setText(DomainConstants.COLUMN_NAME);<o:p></o:p> </FONT></FONT><=
/FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0>new TableColumn(table,=20
SWT.LEFT).setText(DomainConstants.COLUMN_TYPE);<o:p></o:p> </FONT></FONT><=
/FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0>new TableColumn(table,=20
SWT.RIGHT).setText(DomainConstants.COLUMN_STATUS);<o:p></o:p ></FONT></FON=
T></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0>new TableColumn(table,=20
SWT.RIGHT).setText(DomainConstants.COLUMN_PRIORITY);<o:p></o:p ></FONT></F=
ONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0><SPAN=20
style=3D"mso-spacerun: yes"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
</SPAN><o:p></o:p></FONT></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0>// Add drag and drop=20
support.<o:p></o:p></FONT></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DCourier=20
color=3D#0000a0 size=3D2>&nbsp;</FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0>int ops =3D DND.DROP_COPY |=20
DND.DROP_MOVE;<o:p></o:p></FONT></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DCourier=20
color=3D#0000a0 size=3D2>&nbsp;</FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0>Transfer[] transfers =3D new =
Transfer[] {=20
DomainSymbolTransfer.getInstance()};<o:p></o:p></FONT></FONT ></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0>tableTreeViewer.addDragSupport(ops, =
transfers,=20
new =
SymbolDragListener(tableTreeViewer));<o:p></o:p></FONT></FONT ></FONT></P>=

<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0><SPAN=20
style=3D"mso-spacerun: yes"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
</SPAN><o:p></o:p></FONT></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2><FONT=20
face=3DCourier><FONT color=3D#0000a0>dropAdapter =3D new=20
TableTreeDropAdapter(tableTreeViewer);<o:p></o:p></FONT></FONT ></FONT></P=
>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT face=3DCourier =
color=3D#0000a0=20
size=3D2>tableTreeViewer.addDropSupport(ops, transfers,=20
dropAdapter);</FONT></P></DIV></BODY></HTML>

------=_NextPart_000_0006_01C4FFC9.898BDAD0--
Re: DND within TableTree? [message #449347 is a reply to message #449338] Sat, 22 January 2005 20:20 Go to previous messageGo to next message
Boris Bokowski is currently offline Boris BokowskiFriend
Messages: 272
Registered: July 2009
Senior Member
The TableTreeViewer registers your DragSourceListener with the TableTree
control. To get DND to work, the listener has to be registered with the
underlying Table control, like in:

DragSource dragSource = new
DragSource(tableTreeViewer.getTableTree().getTable(), ops);
dragSource.setTransfer(transfers);
dragSource.addDragListener(new SymbolDragListener(tableTreeViewer));

You can do the same for drop. For your class TableTreeDropAdapter, this is
the hack to determine the drop target:

protected Object determineTarget(DropTargetEvent event) {
Object tableTreeItem = event.item == null ? null :
event.item.getData("TableTreeItemID");
return tableTreeItem == null ? null : ((TableTreeItem)
tableTreeItem).getData();
}

The JFace team says this is a bug in SWT (see bugzilla #38840). Apparently,
native table trees are coming up for 3.1 (see #36822).

/Boris

=====================
"Mighty M" <fn2o-mycl@spamex.com> wrote:

When I converted my TreeViewer to a TableTreeViewer, the drag-and-drop
support broke. Performing a selection and drag gesture no longer initiates a
drag operation. The dragStart() method is never evoked. Are there any known
issues that prevent dragging and dropping within the TableTree? Do I need
to supply a special TableTreeViewer SWT style to enable dragging? Please
help.

Thanks,
Mark

reply to: fn2o-mycl@spamex.com

==========
tableTreeViewer = new TableTreeViewer(parent, SWT.FULL_SELECTION +
SWT.MULTI);
tableTreeViewer.setContentProvider( new DomainContentProvider () );
labelProvider = new DomainLabelProvider ();
tableTreeViewer.setLabelProvider(labelProvider);
tableTreeViewer.setUseHashlookup(true);

tableTreeViewer.setInput (getInitalInput());

Table table = tableTreeViewer.getTableTree().getTable();
new TableColumn(table, SWT.LEFT).setText(DomainConstants.COLUMN_NAME);
new TableColumn(table, SWT.LEFT).setText(DomainConstants.COLUMN_TYPE);
new TableColumn(table, SWT.RIGHT).setText(DomainConstants.COLUMN_STATUS);
new TableColumn(table, SWT.RIGHT).setText(DomainConstants.COLUMN_PRIORITY);

// Add drag and drop support.

int ops = DND.DROP_COPY | DND.DROP_MOVE;

Transfer[] transfers = new Transfer[] { DomainSymbolTransfer.getInstance()};
tableTreeViewer.addDragSupport(ops, transfers, new
SymbolDragListener(tableTreeViewer));

dropAdapter = new TableTreeDropAdapter(tableTreeViewer);
tableTreeViewer.addDropSupport(ops, transfers, dropAdapter);
Re: DND within TableTree? [message #449473 is a reply to message #449347] Tue, 25 January 2005 12:37 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
TreeViewer with columns supported for 3.1 Jan 25 Integration build. Here is
an example of setting fonts, colours, image and text:

public class TreeViewerTest {

class TreeViewerTestLabelProvider implements ITableLabelProvider,
ITableColorProvider, ITableFontProvider {
Font font = null;
public String getColumnText(Object element, int columnIndex)
{
if (!(element instanceof File)) return null;
File file = (File)element;
switch (columnIndex) {
case 0:
return file.getName();
case 1:
return ""+new Date(file.lastModified());
case 2:
return ""+file.isHidden();
}
return null;
}
public Image getColumnImage(Object element, int columnIndex)
{
if (columnIndex != 0) return null;
if (!(element instanceof File)) return null;
File file = (File)element;
Display display = Display.getCurrent();
if (file.isDirectory()) return
display.getSystemImage(SWT.ICON_WARNING);
return display.getSystemImage(SWT.ICON_QUESTION);
}
public void dispose() {
if (font != null) font.dispose();
font = null;
}
public boolean isLabelProperty(Object element, String
property) {
return false;
}
public void addListener(ILabelProviderListener listener) {
}
public void removeListener(ILabelProviderListener listener)
{
}
public Color getForeground(Object element, int columnIndex)
{
if (columnIndex == 1) {
Display display = Display.getCurrent();
return
display.getSystemColor(SWT.COLOR_RED);
}
return null;
}
public Color getBackground(Object element, int columnIndex)
{
if (columnIndex == 0) {
File file = (File)element;
Display display = Display.getCurrent();
if (file.isDirectory()) return
display.getSystemColor(SWT.COLOR_CYAN);
return
display.getSystemColor(SWT.COLOR_MAGENTA);
}
return null;
}
public Font getFont(Object element, int columnIndex) {
if (columnIndex == 2) {
if (font == null) {
Display display =
Display.getCurrent();
font = new Font(display, "Times",
12, SWT.ITALIC);
}
return font;
}
return null;
}
}
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FormLayout());

TreeViewerTestLabelProvider labelProvider1 = new
TreeViewerTest().new TreeViewerTestLabelProvider();
ITreeContentProvider contentProvider = new ITreeContentProvider() {
public Object[] getChildren(Object parentElement) {
if (!(parentElement instanceof File)) return null;
File file = (File)parentElement;
if (file.isDirectory()) return file.listFiles();
return null;
}

public Object getParent(Object element) {
if (!(element instanceof File)) return null;
File file = (File)element;
return file.getParentFile();
}

public boolean hasChildren(Object element) {
if (!(element instanceof File)) return false;
File file = (File)element;
return file.isDirectory();
}

public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}

public void dispose() {
}

public void inputChanged(Viewer viewer, Object oldInput,
Object newInput) {
}
};

final TreeViewer treeViewer1 = new TreeViewer(shell,
SWT.FULL_SELECTION | SWT.CHECK);
Tree tree1 = treeViewer1.getTree();
tree1.setHeaderVisible(true);
TreeColumn column1 = new TreeColumn(tree1, SWT.LEFT);
column1.setText("Name");
column1.setImage(display.getSystemImage(SWT.ICON_WORKING));
column1.setWidth(200);
TreeColumn column2 = new TreeColumn(tree1, SWT.CENTER);
column2.setText("Last Modified");
column2.setImage(display.getSystemImage(SWT.ICON_INFORMATION ));
column2.setWidth(200);
TreeColumn column3 = new TreeColumn(tree1, SWT.CENTER);
column3.setText("Hidden");
column3.setImage(display.getSystemImage(SWT.ICON_INFORMATION ));
column3.setWidth(100);
treeViewer1.setLabelProvider(labelProvider1);
treeViewer1.setContentProvider(contentProvider);

Button b = new Button(shell, SWT.PUSH);
b.setText("choose root folder");
b.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
DirectoryDialog f = new DirectoryDialog(shell,
SWT.OPEN);
String root = f.open();
if (root != null) {
File file = new File(root);
if (file.exists()) {
treeViewer1.setInput(file);
treeViewer1.refresh();
treeViewer2.setInput(file);
treeViewer2.refresh();
}
}
}
});

FormData data = new FormData();
data.left = new FormAttachment(0, 10);
data.top = new FormAttachment(0, 10);
data.right = new FormAttachment(100, -10);
data.bottom = new FormAttachment(b, -10);
tree1.setLayoutData(data);

data = new FormData();
data.left = new FormAttachment(0, 10);
data.bottom = new FormAttachment(100, -10);
b.setLayoutData(data);

shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}

"Boris Bokowski" <borisnews@bokowski.de> wrote in message
news:csucj9$ap2$1@www.eclipse.org...
> The TableTreeViewer registers your DragSourceListener with the TableTree
> control. To get DND to work, the listener has to be registered with the
> underlying Table control, like in:
>
> DragSource dragSource = new
> DragSource(tableTreeViewer.getTableTree().getTable(), ops);
> dragSource.setTransfer(transfers);
> dragSource.addDragListener(new SymbolDragListener(tableTreeViewer));
>
> You can do the same for drop. For your class TableTreeDropAdapter, this is
> the hack to determine the drop target:
>
> protected Object determineTarget(DropTargetEvent event) {
> Object tableTreeItem = event.item == null ? null :
> event.item.getData("TableTreeItemID");
> return tableTreeItem == null ? null : ((TableTreeItem)
> tableTreeItem).getData();
> }
>
> The JFace team says this is a bug in SWT (see bugzilla #38840).
> Apparently, native table trees are coming up for 3.1 (see #36822).
>
> /Boris
>
> =====================
> "Mighty M" <fn2o-mycl@spamex.com> wrote:
>
> When I converted my TreeViewer to a TableTreeViewer, the drag-and-drop
> support broke. Performing a selection and drag gesture no longer initiates
> a drag operation. The dragStart() method is never evoked. Are there any
> known issues that prevent dragging and dropping within the TableTree? Do
> I need to supply a special TableTreeViewer SWT style to enable dragging?
> Please help.
>
> Thanks,
> Mark
>
> reply to: fn2o-mycl@spamex.com
>
> ==========
> tableTreeViewer = new TableTreeViewer(parent, SWT.FULL_SELECTION +
> SWT.MULTI);
> tableTreeViewer.setContentProvider( new DomainContentProvider () );
> labelProvider = new DomainLabelProvider ();
> tableTreeViewer.setLabelProvider(labelProvider);
> tableTreeViewer.setUseHashlookup(true);
>
> tableTreeViewer.setInput (getInitalInput());
>
> Table table = tableTreeViewer.getTableTree().getTable();
> new TableColumn(table, SWT.LEFT).setText(DomainConstants.COLUMN_NAME);
> new TableColumn(table, SWT.LEFT).setText(DomainConstants.COLUMN_TYPE);
> new TableColumn(table, SWT.RIGHT).setText(DomainConstants.COLUMN_STATUS);
> new TableColumn(table,
> SWT.RIGHT).setText(DomainConstants.COLUMN_PRIORITY);
>
> // Add drag and drop support.
>
> int ops = DND.DROP_COPY | DND.DROP_MOVE;
>
> Transfer[] transfers = new Transfer[] {
> DomainSymbolTransfer.getInstance()};
> tableTreeViewer.addDragSupport(ops, transfers, new
> SymbolDragListener(tableTreeViewer));
>
> dropAdapter = new TableTreeDropAdapter(tableTreeViewer);
> tableTreeViewer.addDropSupport(ops, transfers, dropAdapter);
>
Re: DND within TableTree? [message #453195 is a reply to message #449347] Thu, 31 March 2005 11:13 Go to previous message
Steve is currently offline SteveFriend
Messages: 1
Registered: July 2009
Junior Member
Boris Bokowski wrote:
> The TableTreeViewer registers your DragSourceListener with the TableTree
> control. To get DND to work, the listener has to be registered with the
> underlying Table control, like in:
<snip>

We got that working under Windows, but not under Linux (gtk). Does
anyone know if it's possible to get DND working for TableTree on gtk?
I presume this means I'm really asking just whether SWT Table supports
DND on gtk.

--
Steve Toledo-Brown
Speaking for myself only.
Previous Topic:AWT_SWT on mac osx
Next Topic:SWT from Common Lisp
Goto Forum:
  


Current Time: Sat Jul 20 21:53:43 GMT 2019

Powered by FUDForum. Page generated in 0.01715 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top