Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 248915 Details for
Bug 428852
[GTK3] SWT - DND broken
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
DND works 50% of the time.
DNDContainersTests.java (text/plain), 8.14 KB, created by
Leo Ufimtsev
on 2014-11-25 09:52:48 EST
(
hide
)
Description:
DND works 50% of the time.
Filename:
MIME Type:
Creator:
Leo Ufimtsev
Created:
2014-11-25 09:52:48 EST
Size:
8.14 KB
patch
obsolete
>package DNDTesting; >import java.awt.GridLayout; > >import javax.swing.border.Border; > >import org.eclipse.swt.*; >import org.eclipse.swt.custom.ST; >import org.eclipse.swt.custom.SashForm; >import org.eclipse.swt.custom.ScrolledComposite; >import org.eclipse.swt.dnd.DND; >import org.eclipse.swt.dnd.DragSource; >import org.eclipse.swt.dnd.DragSourceEvent; >import org.eclipse.swt.dnd.DragSourceListener; >import org.eclipse.swt.dnd.DropTargetEvent; >import org.eclipse.swt.dnd.TextTransfer; >import org.eclipse.swt.dnd.Transfer; >import org.eclipse.swt.widgets.*; >import org.eclipse.swt.dnd.*; >import org.eclipse.swt.graphics.Color; >import org.eclipse.swt.layout.FillLayout; >import org.eclipse.swt.layout.FormLayout; >import org.eclipse.swt.layout.GridData; >import org.eclipse.swt.layout.RowLayout; > >import com.sun.org.apache.xpath.internal.axes.BasicTestIterator; > >public class DNDContainersTests { > > static int WORKING = SWT.COLOR_GREEN; > static int FAILING = SWT.COLOR_RED; > static int NOT_TESTED = SWT.COLOR_YELLOW; > > static enum ContainerType { > compositeFill(WORKING), > compositeGrid(WORKING), > compositeRow(WORKING), > nestedComposite(WORKING), > scrolledComposite(WORKING), > sashform(WORKING), > coolbar(WORKING), > groupWithFill(FAILING), > groupWithGRID(FAILING), > tabfolder(FAILING), > compositeInGroup(FAILING); > > > private int color; > ContainerType(int color) { > this.color = color; > } > public int getColor() { > return this.color; > } > }; > > static Display display = new Display (); > static Shell shell = new Shell (display); > static Transfer [] transferTypes = new Transfer[] {TextTransfer.getInstance ()}; > > public static void main(String[] args) { > configureShell (); > > >// basicTest(); //Uncomment & comment below for debugging a basic test case. > advanceTests(); > > swtMainLoop (); > } > > //DND does not work in a group > private static void basicTest() { > Group group = new Group (shell, SWT.NONE); > group.setLayout (new FillLayout ()); > group.setText ("Source Group"); > createDNDLabelds (group); > } > > > private static void advanceTests() { > for (ContainerType ci : ContainerType.values ()) { > testContainer (shell, ci); > } > } > > private static void testContainer (Composite parent, ContainerType containerType) { > Composite compositeForDNDLabels = null; > switch (containerType) { > case compositeFill:{ > Composite composite = new Composite (parent, SWT.BORDER); > composite.setLayout (new FillLayout ()); > compositeForDNDLabels = composite; > break; > } > case compositeGrid: { > Composite composite = new Composite (parent, SWT.BORDER); > composite.setLayout (new org.eclipse.swt.layout.GridLayout (3, false)); > composite.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); > compositeForDNDLabels = composite; > break; > } > case compositeRow:{ > Composite composite = new Composite (parent, SWT.BORDER); > composite.setLayout (new RowLayout (SWT.HORIZONTAL) ); > compositeForDNDLabels = composite; > > break; > } > case nestedComposite: { > Composite composite = new Composite (parent, SWT.BORDER); > composite.setLayout (new FillLayout ()); > Composite childComposite = new Composite (composite, SWT.None); > childComposite.setLayout (new FillLayout ()); > compositeForDNDLabels = childComposite; > break; > } > case groupWithFill: { > Group group = new Group (parent, SWT.BORDER); > group.setLayout (new FillLayout ()); > group.setText ("Group"); > compositeForDNDLabels = group; > break; > } > case groupWithGRID: { > Group group = new Group (parent, SWT.BORDER); > group.setLayout (new org.eclipse.swt.layout.GridLayout (3, false)); > group.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); > compositeForDNDLabels = group; > break; > } > > case tabfolder: { > //Create a tab Folder. > TabFolder tabFolder = new TabFolder (parent, SWT.BORDER); >// tabFolder.setBackground (display.getSystemColor (containerType.getColor ())); > TabItem tabItem = new TabItem (tabFolder, SWT.BORDER); > tabItem.setText ("TabFolder tab"); > Composite compositeInTab = new Composite (tabFolder, SWT.NONE); > compositeInTab.setLayout (new FillLayout ()); > tabItem.setControl (compositeInTab); > compositeForDNDLabels = compositeInTab; > break; > } > case sashform: { > SashForm sashForm = new SashForm (parent,SWT.HORIZONTAL); > compositeForDNDLabels = sashForm; > break; > } > case scrolledComposite: { > ScrolledComposite scrolledComposite = new ScrolledComposite (parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); > Composite composite = new Composite (scrolledComposite, SWT.BORDER); > composite.setLayout (new RowLayout (SWT.HORIZONTAL)); > compositeForDNDLabels = composite; > break; > } > case compositeInGroup: { > Group group = new Group (parent, SWT.BORDER); > group.setLayout (new FillLayout ()); > group.setText ("Group with composite inside"); > Composite composite = new Composite (group, SWT.BORDER); > composite.setLayout (new FillLayout ()); > compositeForDNDLabels = composite; > break; > } > case coolbar: { > CoolBar coolBar = new CoolBar (parent, SWT.BORDER); > coolBar.setLayout (new FillLayout ()); > CoolItem coolItem = new CoolItem (coolBar, SWT.None); > compositeForDNDLabels = coolBar; > break; > } > > }; > Color backgrounColor = display.getSystemColor (containerType.getColor ()); > compositeForDNDLabels.setBackground (backgrounColor); > labelIt(compositeForDNDLabels, containerType.toString (), backgrounColor); > createDNDLabelds (compositeForDNDLabels); > compositeForDNDLabels.pack (); > } > > private static void labelIt(Composite composite, String labelText, Color color) { > Label label = new Label (composite, SWT.None); > label.setText (labelText); > label.setBackground (color); > } > > private static void createDNDLabelds(Composite composite) { > createDragLabel (composite); > createDropLabel (composite); > } > > > private static void configureShell () { > FillLayout fillLayout = new FillLayout (SWT.VERTICAL); > shell.setLayout(fillLayout); > } > > private static void swtMainLoop () { > shell.setBounds (10, 10, 600, 900); > // shell.pack (); > shell.open (); > while (!shell.isDisposed ()) { > if (!display.readAndDispatch ()) > display.sleep (); > } > display.dispose (); > } > > > private static void createDragLabel (Composite parent) { > final Label dragLabel = new Label(parent, SWT.BORDER); > dragLabel.setText ("Source Widget"); > > //Create a dragsource with the widget as argument: > DragSource source = new DragSource(dragLabel, DND.DROP_MOVE); > source.setTransfer (transferTypes); > > //Add a drag listener. > source.addDragListener (new DragSourceListener() { > @Override > public void dragStart (DragSourceEvent event) { > //only start if there is text in label > if (dragLabel.getText ().length() == 0) { > event.doit = false; > } > } > @Override > public void dragSetData (DragSourceEvent event) { > //provide data for dnd. > if (TextTransfer.getInstance().isSupportedType (event.dataType)) { > event.data = dragLabel.getText (); > } > } > @Override > public void dragFinished (DragSourceEvent event) { > //If move was performed, remove data from source > if (event.detail == DND.DROP_MOVE) { > dragLabel.setText (""); > } > } > }); > } > > > private static void createDropLabel (Composite parent) { > final Label dropLabel = new Label (parent, SWT.BORDER); > dropLabel.setText ("Drag target"); > > //Say that we can drop things on it. > DropTarget target = new DropTarget(dropLabel, DND.DROP_MOVE); > > target.setTransfer (transferTypes); > target.addDropListener (new DropTargetListener() { > > @Override > public void dragEnter (DropTargetEvent event) { > } > > //Print what is being dragged over > @Override > public void dragOver (DropTargetEvent event) { > } > > @Override > public void dragOperationChanged (DropTargetEvent event) {} > > > @Override > public void dropAccept (DropTargetEvent event) {} > > @Override > public void drop (DropTargetEvent event) { > if (transferTypes[0].isSupportedType (event.currentDataType)) { > String textString = (String) event.data; > dropLabel.setText (textString); > } > } > > @Override > public void dragLeave (DropTargetEvent event) {} > }); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 428852
:
243091
|
248167
|
248915
|
248965