public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("SWT and Swing DND Example"); GridLayout layout = new GridLayout(1, false); shell.setLayout(layout); Text swtText = new Text(shell, SWT.BORDER); swtText.setText("SWT Text"); GridData data = new GridData(GridData.FILL_HORIZONTAL); swtText.setLayoutData(data); setDragDrop(swtText); Composite comp = new Composite(shell, SWT.EMBEDDED); java.awt.Frame frame = SWT_AWT.new_Frame(comp); JTextField swingText = new JTextField(40); swingText.setText("Swing Text"); swingText.setDragEnabled(true); frame.add(swingText); data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = swingText.getPreferredSize().height; comp.setLayoutData(data); shell.setSize(400, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
@Override public Configurable[] getConfigurables() { if (!isInitialized) { ArrayList<Configurable> list = new ArrayList<Configurable>(); if (super.myEp.dynamic) { Composite composite = cast(Composite.class, this); if (composite != null) { Collections.addAll(list, composite.getConfigurables()); } } if (super.myEp.children != null) { for (ConfigurableEP ep : super.myEp.getChildren()) { if (ep.isAvailable()) { list.add((Configurable) wrapConfigurable(ep)); } } } if (super.myEp.childrenEPName != null) { Object[] extensions = Extensions.getArea(super.myEp.getProject()) .getExtensionPoint(super.myEp.childrenEPName) .getExtensions(); if (extensions.length > 0) { if (extensions[0] instanceof ConfigurableEP) { for (Object object : extensions) { list.add((Configurable) wrapConfigurable((ConfigurableEP) object)); } } else if (!super.myEp.dynamic) { Composite composite = cast(Composite.class, this); if (composite != null) { Collections.addAll(list, composite.getConfigurables()); } } } } Collections.addAll(list, myKids); // sort configurables is needed for (Configurable configurable : list) { if (configurable instanceof Weighted) { if (((Weighted) configurable).getWeight() != 0) { myComparator = COMPARATOR; Collections.sort(list, myComparator); break; } } } myKids = ArrayUtil.toObjectArray(list, Configurable.class); isInitialized = true; } return myKids; }