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 35463 Details for
Bug 129749
[DND] Drag n' drop links from external browser
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.
Snippet illustrating the DND behaviour
DNDTest.java (text/plain), 6.28 KB, created by
Andre N. Klingsheim
on 2006-02-28 05:34:22 EST
(
hide
)
Description:
Snippet illustrating the DND behaviour
Filename:
MIME Type:
Creator:
Andre N. Klingsheim
Created:
2006-02-28 05:34:22 EST
Size:
6.28 KB
patch
obsolete
> > >import org.eclipse.swt.SWT; >import org.eclipse.swt.graphics.Point; >import org.eclipse.swt.graphics.Rectangle; >import org.eclipse.swt.layout.FillLayout; >import org.eclipse.swt.layout.GridData; >import org.eclipse.swt.layout.GridLayout; >import org.eclipse.swt.widgets.Composite; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Label; >import org.eclipse.swt.widgets.Shell; >import org.eclipse.swt.widgets.Text; >import org.eclipse.swt.dnd.*; > > >public class DNDTest extends org.eclipse.swt.widgets.Composite { > > > private Text text1; > private Text text2; > private Label label1; > > > public DNDTest(Composite parent, int style) { > super(parent, style); > initGUI(); > } > > /** > * Initializes the GUI. > */ > private void initGUI() { > try { > this.setSize(new org.eclipse.swt.graphics.Point(400,300)); > > GridLayout thisLayout = new GridLayout(1, true); > thisLayout.marginWidth = 5; > thisLayout.marginHeight = 5; > thisLayout.numColumns = 1; > thisLayout.makeColumnsEqualWidth = true; > thisLayout.horizontalSpacing = 5; > thisLayout.verticalSpacing = 5; > this.setLayout(thisLayout); > > label1 = new Label(this, SWT.NONE); > GridData label1LData = new GridData(); > label1LData.widthHint = 318; > label1LData.heightHint = 17; > label1.setLayoutData(label1LData); > label1.setText("label1"); > > text1 = new Text(this, SWT.MULTI | SWT.WRAP); > GridData text1LData = new GridData(); > text1LData.widthHint = 370; > text1LData.heightHint = 104; > text1.setLayoutData(text1LData); > text1.setText("Drop links here!"); > > > text2 = new Text(this, SWT.MULTI | SWT.WRAP); > GridData text2LData = new GridData(); > text2LData.widthHint = 358; > text2LData.heightHint = 113; > text2.setLayoutData(text2LData); > text2.setText("text2"); > > > Transfer[] types = new Transfer[] {FileTransfer.getInstance(), > HTMLTransfer.getInstance(), > RTFTransfer.getInstance(), > TextTransfer.getInstance()}; > DropTarget target = new DropTarget(text1, DND.DROP_DEFAULT | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_MOVE); > //DropTarget target = new DropTarget(text1, DND.DROP_DEFAULT| DND.DROP_MOVE); > target.setTransfer(types); > target.addDropListener (new DropTargetAdapter() { > public void drop(DropTargetEvent event) { > switch(event.detail){ > case DND.DROP_NONE: > label1.setText("DROP_NONE"); > break; > /*case DND.DROP_MOVE: > label1.setText("DROP_MOVE"); > break; > case DND.DROP_COPY: > label1.setText("DROP_COPY"); > break; > case DND.DROP_LINK: > label1.setText("DROP_LINK"); > break;*/ > } > > > > > if (FileTransfer.getInstance().isSupportedType(event.currentDataType)){ > System.err.println("FileTransfer supported"); > String[] stuff=(String[])event.data; > if (stuff!=null){ > System.err.println("Files dropped: "+stuff.length); > for (int i = 0; i < stuff.length; i++) { > System.err.println(stuff[i]); > } > }else{ > System.err.println("Data was null "); > } > }else if (HTMLTransfer.getInstance().isSupportedType(event.currentDataType)){ > System.err.println("HTMLTransfer supported"); > String stuff=(String)event.data; > if (stuff!=null){ > System.err.println("HTML dropped: "+stuff); > }else{ > System.err.println("Data was null "); > } > }else if (RTFTransfer.getInstance().isSupportedType(event.currentDataType)){ > System.err.println("RTFTransfer supported"); > String stuff=(String)event.data; > if (stuff!=null){ > System.err.println("RTF dropped: "+stuff); > }else{ > System.err.println("Data was null "); > } > }else if (TextTransfer.getInstance().isSupportedType(event.currentDataType)){ > System.err.println("TextTransfer supported"); > String stuff=(String)event.data; > if (stuff!=null){ > System.err.println("Text dropped: "+stuff); > }else{ > System.err.println("Data was null "); > } > }else{ > System.err.println("Unkown datatype"); > } > > > > } > }); > > this.layout(); > } catch (Exception e) { > e.printStackTrace(); > } > } > > /** > * Auto-generated main method to display this > * org.eclipse.swt.widgets.Composite inside a new Shell. > */ > public static void main(String[] args) { > Display display = Display.getDefault(); > Shell shell = new Shell(display); > DNDTest inst = new DNDTest(shell, SWT.NULL); > Point size = inst.getSize(); > shell.setLayout(new FillLayout()); > shell.layout(); > if(size.x == 0 && size.y == 0) { > inst.pack(); > shell.pack(); > } else { > Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y); > shell.setSize(shellBounds.width, shellBounds.height); > } > shell.open(); > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) > display.sleep(); > } > } > >}
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 129749
: 35463