1 /******************************************************************************* 2 * Copyright (c) 2000, 2016 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.ui.forms.examples.internal.rcp; 15 16 import java.text.MessageFormat; 17 import java.util.ArrayList; 18 19 import org.eclipse.jface.action.Action; 20 import org.eclipse.jface.action.ControlContribution; 21 import org.eclipse.jface.dialogs.IMessageProvider; 22 import org.eclipse.jface.dialogs.MessageDialog; 23 import org.eclipse.swt.SWT; 24 import org.eclipse.swt.dnd.DND; 25 import org.eclipse.swt.dnd.DragSourceEvent; 26 import org.eclipse.swt.dnd.DragSourceListener; 27 import org.eclipse.swt.dnd.DropTargetAdapter; 28 import org.eclipse.swt.dnd.TextTransfer; 29 import org.eclipse.swt.dnd.Transfer; 30 import org.eclipse.swt.events.SelectionAdapter; 31 import org.eclipse.swt.events.SelectionEvent; 32 import org.eclipse.swt.graphics.Color; 33 import org.eclipse.swt.layout.GridData; 34 import org.eclipse.swt.layout.GridLayout; 35 import org.eclipse.swt.widgets.Button; 36 import org.eclipse.swt.widgets.Combo; 37 import org.eclipse.swt.widgets.Composite; 38 import org.eclipse.swt.widgets.Control; 39 import org.eclipse.swt.widgets.Text; 40 import org.eclipse.ui.ISharedImages; 41 import org.eclipse.ui.PlatformUI; 42 import org.eclipse.ui.forms.FormColors; 43 import org.eclipse.ui.forms.HyperlinkSettings; 44 import org.eclipse.ui.forms.IFormColors; 45 import org.eclipse.ui.forms.IManagedForm; 46 import org.eclipse.ui.forms.IMessageManager; 47 import org.eclipse.ui.forms.editor.FormEditor; 48 import org.eclipse.ui.forms.editor.FormPage; 49 import org.eclipse.ui.forms.events.HyperlinkAdapter; 50 import org.eclipse.ui.forms.events.HyperlinkEvent; 51 import org.eclipse.ui.forms.events.IHyperlinkListener; 52 import org.eclipse.ui.forms.examples.internal.ExamplesPlugin; 53 import org.eclipse.ui.forms.widgets.ExpandableComposite; 54 import org.eclipse.ui.forms.widgets.FormToolkit; 55 import org.eclipse.ui.forms.widgets.ScrolledForm; 56 import org.eclipse.ui.forms.widgets.Section; 57 58 /** 59 * @author dejan 60 * 61 * To change the template for this generated type comment go to Window - 62 * Preferences - Java - Code Generation - Code and Comments 63 */ 64 public class NewStylePage extends FormPage { 65 private static final String SHORT_TITLE = "Short Title"; 66 private static final String LONG_TITLE = "This title is somewhat longer"; 67 private static final String SHORT_MESSAGE = "A short {0} message"; 68 private static final String LONG_MESSAGE = "This {0} message is longer and will also compete with other header regions"; 69 private static final String[] MESSAGE_NAMES = { "text", "info", "warning", 70 "error" }; 71 72 /** 73 * @param id 74 * @param title 75 */ NewStylePage(FormEditor editor)76 public NewStylePage(FormEditor editor) { 77 super(editor, "newStyle", "New Style"); 78 } 79 80 @Override createFormContent(IManagedForm managedForm)81 protected void createFormContent(IManagedForm managedForm) { 82 final ScrolledForm form = managedForm.getForm(); 83 final FormToolkit toolkit = managedForm.getToolkit(); 84 toolkit.getHyperlinkGroup().setHyperlinkUnderlineMode( 85 HyperlinkSettings.UNDERLINE_HOVER); 86 87 GridLayout layout = new GridLayout(); 88 layout.numColumns = 2; 89 layout.marginHeight = 10; 90 layout.marginWidth = 6; 91 layout.horizontalSpacing = 20; 92 form.getBody().setLayout(layout); 93 94 Section section = toolkit.createSection(form.getBody(), 95 ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE 96 | ExpandableComposite.EXPANDED); 97 Composite client = toolkit.createComposite(section); 98 section.setClient(client); 99 section.setText("Header features"); 100 section 101 .setDescription("Use the switches below to control basic heading parameters."); 102 GridData gd = new GridData(GridData.FILL_BOTH); 103 section.setLayoutData(gd); 104 layout = new GridLayout(); 105 layout.marginWidth = 0; 106 layout.marginHeight = 0; 107 client.setLayout(layout); 108 final Button tbutton = toolkit.createButton(client, "Add title", 109 SWT.CHECK); 110 final Button sbutton = toolkit.createButton(client, "Short title", 111 SWT.RADIO); 112 sbutton.setSelection(true); 113 sbutton.setEnabled(false); 114 gd = new GridData(); 115 gd.horizontalIndent = 10; 116 sbutton.setLayoutData(gd); 117 final Button lbutton = toolkit.createButton(client, "Long title", 118 SWT.RADIO); 119 gd = new GridData(); 120 gd.horizontalIndent = 10; 121 lbutton.setLayoutData(gd); 122 lbutton.setEnabled(false); 123 final Button titleTextSelectableButton = toolkit.createButton(client, "Make title text selectable", SWT.CHECK); 124 gd = new GridData(); 125 gd.horizontalIndent = 10; 126 titleTextSelectableButton.setLayoutData(gd); 127 titleTextSelectableButton.setEnabled(false); 128 tbutton.addSelectionListener(new SelectionAdapter() { 129 @Override 130 public void widgetSelected(SelectionEvent e) { 131 updateTitle(form, tbutton.getSelection(), sbutton 132 .getSelection()); 133 sbutton.setEnabled(tbutton.getSelection()); 134 lbutton.setEnabled(tbutton.getSelection()); 135 titleTextSelectableButton.setEnabled(tbutton.getSelection()); 136 } 137 }); 138 sbutton.addSelectionListener(new SelectionAdapter() { 139 @Override 140 public void widgetSelected(SelectionEvent e) { 141 updateTitle(form, tbutton.getSelection(), sbutton 142 .getSelection()); 143 } 144 }); 145 lbutton.addSelectionListener(new SelectionAdapter() { 146 @Override 147 public void widgetSelected(SelectionEvent e) { 148 updateTitle(form, tbutton.getSelection(), sbutton 149 .getSelection()); 150 } 151 }); 152 titleTextSelectableButton.addSelectionListener(new SelectionAdapter() { 153 @Override 154 public void widgetSelected(SelectionEvent e) { 155 form.getForm().setTitleTextSelectable(titleTextSelectableButton.getSelection()); 156 } 157 }); 158 final Button ibutton = toolkit.createButton(client, "Add image", 159 SWT.CHECK); 160 ibutton.addSelectionListener(new SelectionAdapter() { 161 @Override 162 public void widgetSelected(SelectionEvent e) { 163 updateImage(form, ibutton.getSelection()); 164 } 165 }); 166 167 final Button tbbutton = toolkit.createButton(client, "Add tool bar", 168 SWT.CHECK); 169 170 final Button albutton = toolkit.createButton(client, "Set tool bar allignment to SWT.BOTTOM", 171 SWT.CHECK); 172 albutton.addSelectionListener(new SelectionAdapter() { 173 @Override 174 public void widgetSelected(SelectionEvent e) { 175 form.getForm().setToolBarVerticalAlignment(albutton.getSelection()?SWT.BOTTOM:SWT.TOP); 176 form.reflow(true); 177 } 178 }); 179 gd = new GridData(); 180 gd.horizontalIndent = 10; 181 albutton.setLayoutData(gd); 182 albutton.setEnabled(false); 183 tbbutton.addSelectionListener(new SelectionAdapter() { 184 @Override 185 public void widgetSelected(SelectionEvent e) { 186 addToolBar(toolkit, form, tbbutton.getSelection()); 187 albutton.setEnabled(tbbutton.getSelection()); 188 } 189 }); 190 191 final Button gbutton = toolkit.createButton(client, 192 "Paint background gradient", SWT.CHECK); 193 gbutton.addSelectionListener(new SelectionAdapter() { 194 @Override 195 public void widgetSelected(SelectionEvent e) { 196 addHeadingGradient(toolkit, form, gbutton.getSelection()); 197 } 198 }); 199 200 final Button clbutton = toolkit.createButton(client, "Add head client", 201 SWT.CHECK); 202 clbutton.addSelectionListener(new SelectionAdapter() { 203 @Override 204 public void widgetSelected(SelectionEvent e) { 205 addHeadClient(toolkit, form, clbutton.getSelection()); 206 } 207 }); 208 209 final Button mbutton = toolkit.createButton(client, 210 "Add drop-down menu", SWT.CHECK); 211 mbutton.addSelectionListener(new SelectionAdapter() { 212 @Override 213 public void widgetSelected(SelectionEvent e) { 214 addMenu(toolkit, form, mbutton.getSelection()); 215 } 216 }); 217 218 final Button dbutton = toolkit.createButton(client, "Add drag support", 219 SWT.CHECK); 220 dbutton.addSelectionListener(new SelectionAdapter() { 221 @Override 222 public void widgetSelected(SelectionEvent e) { 223 if (dbutton.getSelection()) { 224 addDragSupport(form); 225 dbutton.setEnabled(false); 226 } 227 } 228 }); 229 230 section = toolkit.createSection(form.getBody(), 231 ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE 232 | ExpandableComposite.EXPANDED); 233 Composite client2 = toolkit.createComposite(section); 234 section.setClient(client2); 235 section.setText("Messages and active state"); 236 section 237 .setDescription("Use the buttons below to control messages and active state."); 238 gd = new GridData(GridData.FILL_BOTH); 239 section.setLayoutData(gd); 240 241 layout = new GridLayout(); 242 layout.marginWidth = 0; 243 layout.marginHeight = 0; 244 layout.numColumns = 4; 245 client2.setLayout(layout); 246 247 final Button shortMessage = toolkit.createButton(client2, 248 "Short message", SWT.RADIO); 249 shortMessage.setSelection(true); 250 gd = new GridData(); 251 gd.horizontalSpan = 4; 252 shortMessage.setLayoutData(gd); 253 final Button longMessage = toolkit.createButton(client2, "Long message", 254 SWT.RADIO); 255 gd = new GridData(); 256 gd.horizontalSpan = 4; 257 longMessage.setLayoutData(gd); 258 259 final IHyperlinkListener listener = new HyperlinkAdapter() { 260 @Override 261 public void linkActivated(HyperlinkEvent e) { 262 String title = e.getLabel(); 263 String details = (String)e.getHref(); 264 if (details==null) { 265 details = title; 266 title = null; 267 } 268 switch (form.getForm().getMessageType()) { 269 case IMessageProvider.NONE: 270 case IMessageProvider.INFORMATION: 271 if (title==null) 272 title = "Forms Information"; 273 MessageDialog.openInformation(form.getShell(), title, details); 274 break; 275 case IMessageProvider.WARNING: 276 if (title==null) 277 title = "Forms Warning"; 278 MessageDialog.openWarning(form.getShell(), title, details); 279 break; 280 case IMessageProvider.ERROR: 281 if (title==null) 282 title = "Forms Error"; 283 MessageDialog.openError(form.getShell(), title, details); 284 break; 285 } 286 } 287 }; 288 289 final Button hyperMessage = toolkit.createButton(client2, 290 "Message as hyperlink", SWT.CHECK); 291 gd = new GridData(); 292 gd.horizontalSpan = 4; 293 hyperMessage.setLayoutData(gd); 294 hyperMessage.addSelectionListener(new SelectionAdapter() { 295 @Override 296 public void widgetSelected(SelectionEvent e) { 297 if (hyperMessage.getSelection()) 298 form.getForm().addMessageHyperlinkListener(listener); 299 else 300 form.getForm().removeMessageHyperlinkListener(listener); 301 } 302 }); 303 304 Control[] children = client.getChildren(); 305 ArrayList<Button> buttons = new ArrayList<>(); 306 for (Control element : children) { 307 if (element instanceof Button) { 308 Button button = (Button) element; 309 if ((button.getStyle() & SWT.CHECK) != 0 && !button.equals(dbutton)) { 310 buttons.add(button); 311 } 312 } 313 } 314 final Button[] checkboxes = buttons.toArray(new Button[buttons.size()]); 315 316 final Button manageMessage = toolkit.createButton(client2, 317 "Use message manager", SWT.CHECK); 318 gd = new GridData(); 319 gd.horizontalSpan = 4; 320 manageMessage.setLayoutData(gd); 321 322 SelectionAdapter mmListener = new SelectionAdapter() { 323 @Override 324 public void widgetSelected(SelectionEvent e) { 325 if (manageMessage.getSelection() && e.widget instanceof Button) 326 addRemoveMessage((Button) e.widget, form.getMessageManager()); 327 } 328 }; 329 for (Button checkbox : checkboxes) 330 checkbox.addSelectionListener(mmListener); 331 332 final Button autoUpdate = toolkit.createButton(client2, 333 "Auto update message manager", SWT.CHECK); 334 gd = new GridData(); 335 gd.horizontalSpan = 4; 336 autoUpdate.setLayoutData(gd); 337 autoUpdate.setSelection(true); 338 autoUpdate.setEnabled(false); 339 autoUpdate.addSelectionListener(new SelectionAdapter() { 340 @Override 341 public void widgetSelected(SelectionEvent e) { 342 form.getMessageManager().setAutoUpdate(autoUpdate.getSelection()); 343 } 344 }); 345 346 shortMessage.addSelectionListener(new SelectionAdapter() { 347 @Override 348 public void widgetSelected(SelectionEvent e) { 349 form.setMessage(getErrorMessage(form.getMessageType(), 350 longMessage.getSelection()), form.getMessageType()); 351 } 352 }); 353 longMessage.addSelectionListener(new SelectionAdapter() { 354 @Override 355 public void widgetSelected(SelectionEvent e) { 356 form.setMessage(getErrorMessage(form.getMessageType(), 357 longMessage.getSelection()), form.getMessageType()); 358 } 359 }); 360 361 final Button error = toolkit.createButton(client2, "Error", SWT.PUSH); 362 error.addSelectionListener(new SelectionAdapter() { 363 @Override 364 public void widgetSelected(SelectionEvent e) { 365 form.setMessage(getErrorMessage(IMessageProvider.ERROR, 366 longMessage.getSelection()), IMessageProvider.ERROR); 367 368 } 369 }); 370 final Button warning = toolkit.createButton(client2, "Warning", SWT.PUSH); 371 warning.addSelectionListener(new SelectionAdapter() { 372 @Override 373 public void widgetSelected(SelectionEvent e) { 374 form.setMessage(getErrorMessage(IMessageProvider.WARNING, 375 longMessage.getSelection()), IMessageProvider.WARNING); 376 } 377 }); 378 final Button info = toolkit.createButton(client2, "Info", SWT.PUSH); 379 info.addSelectionListener(new SelectionAdapter() { 380 @Override 381 public void widgetSelected(SelectionEvent e) { 382 form.setMessage(getErrorMessage(IMessageProvider.INFORMATION, 383 longMessage.getSelection()), 384 IMessageProvider.INFORMATION); 385 } 386 }); 387 final Button cancel = toolkit.createButton(client2, "Cancel", SWT.PUSH); 388 cancel.addSelectionListener(new SelectionAdapter() { 389 @Override 390 public void widgetSelected(SelectionEvent e) { 391 form.setMessage(null, 0); 392 } 393 }); 394 manageMessage.addSelectionListener(new SelectionAdapter() { 395 @Override 396 public void widgetSelected(SelectionEvent e) { 397 boolean selection = manageMessage.getSelection(); 398 if (!selection) 399 autoUpdate.setSelection(true); 400 autoUpdate.setEnabled(selection); 401 IMessageManager mm = form.getMessageManager(); 402 mm.setAutoUpdate(false); 403 if (selection) { 404 for (Button checkbox : checkboxes) { 405 addRemoveMessage(checkbox, mm); 406 } 407 } 408 else { 409 mm.removeAllMessages(); 410 } 411 mm.setAutoUpdate(true); 412 error.setEnabled(!selection); 413 warning.setEnabled(!selection); 414 info.setEnabled(!selection); 415 cancel.setEnabled(!selection); 416 if (selection) { 417 hyperMessage.setSelection(false); 418 form.getForm().removeMessageHyperlinkListener(listener); 419 } 420 hyperMessage.setEnabled(!selection); 421 } 422 }); 423 424 final Button busy = toolkit.createButton(client2, "Start Progress", 425 SWT.PUSH); 426 busy.addSelectionListener(new SelectionAdapter() { 427 @Override 428 public void widgetSelected(SelectionEvent e) { 429 // IWorkbenchSiteProgressService service = 430 // (IWorkbenchSiteProgressService)getSite().getAdapter(IWorkbenchSiteProgressService.class); 431 432 if (form.getForm().isBusy()) { 433 form.getForm().setBusy(false); 434 busy.setText("Start Progress"); 435 } else { 436 form.getForm().setBusy(true); 437 busy.setText("Stop Progress"); 438 } 439 } 440 }); 441 gd = new GridData(); 442 gd.horizontalSpan = 2; 443 busy.setLayoutData(gd); 444 } 445 addHeadingGradient(FormToolkit toolkit, ScrolledForm form, boolean add)446 private void addHeadingGradient(FormToolkit toolkit, ScrolledForm form, 447 boolean add) { 448 FormColors colors = toolkit.getColors(); 449 Color top = colors.getColor(IFormColors.H_GRADIENT_END); 450 Color bot = colors.getColor(IFormColors.H_GRADIENT_START); 451 if (add) 452 form.getForm().setTextBackground(new Color[] { top, bot }, 453 new int[] { 100 }, true); 454 else { 455 form.getForm().setTextBackground(null, null, false); 456 form.getForm().setBackground(colors.getBackground()); 457 } 458 form.getForm().setHeadColor(IFormColors.H_BOTTOM_KEYLINE1, 459 add ? colors.getColor(IFormColors.H_BOTTOM_KEYLINE1) : null); 460 form.getForm().setHeadColor(IFormColors.H_BOTTOM_KEYLINE2, 461 add ? colors.getColor(IFormColors.H_BOTTOM_KEYLINE2) : null); 462 form.getForm().setHeadColor(IFormColors.H_HOVER_LIGHT, 463 add ? colors.getColor(IFormColors.H_HOVER_LIGHT) : null); 464 form.getForm().setHeadColor(IFormColors.H_HOVER_FULL, 465 add ? colors.getColor(IFormColors.H_HOVER_FULL) : null); 466 form.getForm().setHeadColor(IFormColors.TB_TOGGLE, 467 add ? colors.getColor(IFormColors.TB_TOGGLE) : null); 468 form.getForm().setHeadColor(IFormColors.TB_TOGGLE_HOVER, 469 add ? colors.getColor(IFormColors.TB_TOGGLE_HOVER) : null); 470 form.getForm().setSeparatorVisible(add); 471 form.reflow(true); 472 form.redraw(); 473 } 474 getErrorMessage(int type, boolean longMessage)475 private String getErrorMessage(int type, boolean longMessage) { 476 String name = MESSAGE_NAMES[type]; 477 if (longMessage) 478 return MessageFormat.format(LONG_MESSAGE, new Object[] { name }); 479 else 480 return MessageFormat.format(SHORT_MESSAGE, new Object[] { name }); 481 } 482 updateTitle(ScrolledForm form, boolean addTitle, boolean shortTitle)483 private void updateTitle(ScrolledForm form, boolean addTitle, 484 boolean shortTitle) { 485 if (addTitle) { 486 String text = shortTitle ? SHORT_TITLE : LONG_TITLE; 487 form.setText(text); 488 } else { 489 form.setText(null); 490 } 491 } 492 updateImage(ScrolledForm form, boolean addImage)493 private void updateImage(ScrolledForm form, boolean addImage) { 494 if (addImage) 495 form.setImage(PlatformUI.getWorkbench().getSharedImages().getImage( 496 ISharedImages.IMG_DEF_VIEW)); 497 else 498 form.setImage(null); 499 } 500 addRemoveMessage(Button button, IMessageManager mm)501 private void addRemoveMessage(Button button, IMessageManager mm) { 502 if (button.getSelection()) 503 mm.addMessage(button, button.getText() + " is checked.", null, IMessageProvider.INFORMATION, button); 504 else 505 mm.removeMessage(button, button); 506 } 507 addToolBar(FormToolkit toolkit, ScrolledForm form, boolean add)508 private void addToolBar(FormToolkit toolkit, ScrolledForm form, boolean add) { 509 if (add) { 510 Action haction = new Action("hor", Action.AS_RADIO_BUTTON) { 511 @Override 512 public void run() { 513 } 514 }; 515 haction.setChecked(true); 516 haction.setToolTipText("Horizontal orientation"); 517 haction.setImageDescriptor(ExamplesPlugin.getDefault() 518 .getImageRegistry().getDescriptor( 519 ExamplesPlugin.IMG_HORIZONTAL)); 520 Action vaction = new Action("ver", Action.AS_RADIO_BUTTON) { 521 @Override 522 public void run() { 523 } 524 }; 525 vaction.setChecked(false); 526 vaction.setToolTipText("Vertical orientation"); 527 vaction.setImageDescriptor(ExamplesPlugin.getDefault() 528 .getImageRegistry().getDescriptor( 529 ExamplesPlugin.IMG_VERTICAL)); 530 ControlContribution save = new ControlContribution("save") { 531 @Override 532 protected Control createControl(Composite parent) { 533 Button saveButton = new Button(parent, SWT.PUSH); 534 saveButton.setText("Save"); 535 return saveButton; 536 } 537 }; 538 form.getToolBarManager().add(haction); 539 form.getToolBarManager().add(vaction); 540 form.getToolBarManager().add(save); 541 form.getToolBarManager().update(true); 542 } else { 543 form.getToolBarManager().removeAll(); 544 } 545 form.reflow(true); 546 } 547 addMenu(FormToolkit toolkit, ScrolledForm form, boolean add)548 private void addMenu(FormToolkit toolkit, ScrolledForm form, boolean add) { 549 if (add) { 550 Action haction = new Action("hor", Action.AS_RADIO_BUTTON) { 551 @Override 552 public void run() { 553 } 554 }; 555 haction.setChecked(true); 556 haction.setText("Horizontal"); 557 haction.setToolTipText("Horizontal orientation"); 558 haction.setImageDescriptor(ExamplesPlugin.getDefault() 559 .getImageRegistry().getDescriptor( 560 ExamplesPlugin.IMG_HORIZONTAL)); 561 Action vaction = new Action("ver", Action.AS_RADIO_BUTTON) { 562 @Override 563 public void run() { 564 } 565 }; 566 vaction.setChecked(false); 567 vaction.setText("Vertical"); 568 vaction.setToolTipText("Vertical orientation"); 569 vaction.setImageDescriptor(ExamplesPlugin.getDefault() 570 .getImageRegistry().getDescriptor( 571 ExamplesPlugin.IMG_VERTICAL)); 572 form.getForm().getMenuManager().add(haction); 573 form.getForm().getMenuManager().add(vaction); 574 } else { 575 form.getForm().getMenuManager().removeAll(); 576 } 577 form.reflow(true); 578 } 579 addHeadClient(FormToolkit toolkit, ScrolledForm form, boolean add)580 private void addHeadClient(FormToolkit toolkit, ScrolledForm form, 581 boolean add) { 582 if (add) { 583 Composite headClient = new Composite(form.getForm().getHead(), 584 SWT.NULL); 585 GridLayout glayout = new GridLayout(); 586 glayout.marginWidth = glayout.marginHeight = 0; 587 glayout.numColumns = 3; 588 headClient.setLayout(glayout); 589 Text t = new Text(headClient, toolkit.getBorderStyle()); 590 t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 591 new Combo(headClient, SWT.NULL); 592 new Combo(headClient, SWT.NULL); 593 toolkit.paintBordersFor(headClient); 594 form.setHeadClient(headClient); 595 } else { 596 Control client = form.getForm().getHeadClient(); 597 if (client != null) { 598 client.dispose(); 599 form.setHeadClient(null); 600 } 601 } 602 } 603 addDragSupport(final ScrolledForm form)604 private void addDragSupport(final ScrolledForm form) { 605 int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK; 606 Transfer[] transferTypes = { TextTransfer.getInstance() }; 607 form.getForm().addTitleDragSupport(operations, transferTypes, 608 new DragSourceListener() { 609 @Override 610 public void dragFinished(DragSourceEvent event) { 611 } 612 613 @Override 614 public void dragSetData(DragSourceEvent event) { 615 event.data = form.getForm().getText(); 616 } 617 618 @Override 619 public void dragStart(DragSourceEvent event) { 620 event.doit = true; 621 } 622 }); 623 form.getForm().addTitleDropSupport(operations, transferTypes, 624 new DropTargetAdapter() { 625 }); 626 } 627 } 628