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 66364 Details for
Bug 186038
[DND] On Linux-gtk, the SWT.Activate event is not fired to the popup shell during a dragging operation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Sinppet to demo the missing of SWT.Activate event fired to the dropdown shell during a draggin operation on Linux
DragAndDropApp.java (text/plain), 5.67 KB, created by
Mei Thom
on 2007-05-08 17:07:34 EDT
(
hide
)
Description:
Sinppet to demo the missing of SWT.Activate event fired to the dropdown shell during a draggin operation on Linux
Filename:
MIME Type:
Creator:
Mei Thom
Created:
2007-05-08 17:07:34 EDT
Size:
5.67 KB
patch
obsolete
>package com.ibm.dragdrop; > > >import org.eclipse.swt.SWT; >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.DropTarget; >import org.eclipse.swt.dnd.DropTargetEvent; >import org.eclipse.swt.dnd.DropTargetListener; >import org.eclipse.swt.dnd.TextTransfer; >import org.eclipse.swt.dnd.Transfer; >import org.eclipse.swt.events.DisposeEvent; >import org.eclipse.swt.events.DisposeListener; >import org.eclipse.swt.events.SelectionAdapter; >import org.eclipse.swt.events.SelectionEvent; >import org.eclipse.swt.graphics.Point; >import org.eclipse.swt.graphics.Rectangle; >import org.eclipse.swt.layout.GridLayout; >import org.eclipse.swt.layout.RowLayout; >import org.eclipse.swt.widgets.Button; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Event; >import org.eclipse.swt.widgets.Listener; >import org.eclipse.swt.widgets.Shell; > > >public class DragAndDropApp { > > public static void main(String[] args) { > > Display display = new Display(); > final Shell shell = new Shell(display); > GridLayout layout = new GridLayout(); > layout.numColumns = 2; > shell.setLayout(layout); > > // create the drop down shell > final Shell dropDownShell = new Shell(shell, SWT.ON_TOP | SWT.DROP_DOWN); > dropDownShell.setLayout(new RowLayout()); > dropDownShell.setVisible(false); > > dropDownShell.addListener(SWT.Activate, new Listener() { > public void handleEvent(Event event) { > System.out.println("dropDownShell gets Activate event!"); > } > }); > > dropDownShell.addListener(SWT.Deactivate, new Listener() { > public void handleEvent(Event event) { > System.out.println("dropDownShell entering Deactivate event handler and will hide the dropdown shell"); > hideDropDown(dropDownShell); > } > }); > > dropDownShell.addListener(SWT.Close, new Listener() { > public void handleEvent(Event event) { > hideDropDown(dropDownShell); > } > }); > > > // create the button1 and when it is hovered, display the dropdown > final Button button1 = new Button(shell, SWT.PUSH); > button1.setText("Drop target"); > button1.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > if (!dropDownShell.isVisible()) { > showDropDown(button1, dropDownShell); > } > } > }); > > int operations = DND.DROP_COPY | DND.DROP_DEFAULT; > DropTarget target = new DropTarget(button1, operations); > // Provide data in Text format > Transfer[] types = new Transfer[] {TextTransfer.getInstance()}; > target.setTransfer(types); > > target.addDropListener(new DropTargetListener() { > public void dragEnter(DropTargetEvent event) { > if (event.detail == DND.DROP_DEFAULT) { > if ((event.operations & DND.DROP_COPY) != 0) { > event.detail = DND.DROP_COPY; > } else { > event.detail = DND.DROP_NONE; > } > } > for (int i = 0; i < event.dataTypes.length; i++) { > if (TextTransfer.getInstance().isSupportedType(event.dataTypes[i])){ > event.currentDataType = event.dataTypes[i]; > if (event.detail != DND.DROP_COPY) { > event.detail = DND.DROP_NONE; > } > break; > } > } > } > > public void dragOver(DropTargetEvent event) { > event.feedback = DND.FEEDBACK_SELECT; > > if (!dropDownShell.isVisible()) { > showDropDown(button1, dropDownShell); > } > } > > public void dragOperationChanged(DropTargetEvent event) { > > } > > public void dragLeave(DropTargetEvent event) { } > > public void dropAccept(DropTargetEvent event) { } > > public void drop(DropTargetEvent event) { > if (TextTransfer.getInstance().isSupportedType(event.currentDataType)) { > String text = (String)event.data; > System.out.println(text); > } > } > }); > > > // create the button2 as the drag source > final Button button2 = new Button(shell, SWT.PUSH); > button2.setText("Drag source"); > > operations = DND.DROP_COPY; > DragSource source = new DragSource(button2, operations); > > // Provide data in Text format > source.setTransfer(types); > > source.addDragListener(new DragSourceListener() { > public void dragStart(DragSourceEvent event) { > if (button2.getText().length() == 0) { > event.doit = false; > } > } > public void dragSetData(DragSourceEvent event) { > // Provide the data of the requested type. > if (TextTransfer.getInstance().isSupportedType(event.dataType)) { > event.data = button2.getText(); > } > } > public void dragFinished(DragSourceEvent event) { > > } > }); > > > shell.setSize(300, 300); > shell.addDisposeListener(new DisposeListener () { > public void widgetDisposed(DisposeEvent e) { > if (dropDownShell != null && !dropDownShell.isDisposed()) { > dropDownShell.dispose(); > } > } > }); > shell.open(); > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) > display.sleep(); > } > display.dispose(); > } > > private static void showDropDown(final Button button1, final Shell dropDownShell) { > if (dropDownShell != null && !dropDownShell.isDisposed()) { > dropDownShell.setText("This is a drop down shell"); > dropDownShell.setSize(100, 200); > Rectangle buttonRect = button1.getBounds(); > Point p = button1.getParent().toDisplay(new Point(buttonRect.x, buttonRect.y + buttonRect.height)); > dropDownShell.setLocation(p.x, p.y); > dropDownShell.setVisible(true); > dropDownShell.setFocus(); > } > } > > private static void hideDropDown(final Shell dropDownShell) { > dropDownShell.setVisible(false); > } >} >
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 186038
: 66364