List of usage examples for org.eclipse.swt.custom StyledText copy
public void copy()
DND.CLIPBOARD
clipboard. From source file:LayoutExample.java
/** * Creates the "control" widget children. Subclasses override this method to * augment the standard controls created. */// w w w .j ava 2 s .com void createControlWidgets() { createChildGroup(); code = new Button(controlGroup, SWT.PUSH); code.setText(LayoutExample.getResourceString("Code")); GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = 2; code.setLayoutData(gridData); code.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { final Shell shell = new Shell(); shell.setText(LayoutExample.getResourceString("Generated_Code")); shell.setLayout(new FillLayout()); final StyledText text = new StyledText(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); String layoutCode = generateCode().toString(); if (layoutCode.length() == 0) return; text.setText(layoutCode); Menu bar = new Menu(shell, SWT.BAR); shell.setMenuBar(bar); MenuItem editItem = new MenuItem(bar, SWT.CASCADE); editItem.setText(LayoutExample.getResourceString("Edit")); Menu menu = new Menu(bar); MenuItem select = new MenuItem(menu, SWT.PUSH); select.setText(LayoutExample.getResourceString("Select_All")); select.setAccelerator(SWT.MOD1 + 'A'); select.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { text.selectAll(); } }); MenuItem copy = new MenuItem(menu, SWT.PUSH); copy.setText(LayoutExample.getResourceString("Copy")); copy.setAccelerator(SWT.MOD1 + 'C'); copy.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { text.copy(); } }); MenuItem exit = new MenuItem(menu, SWT.PUSH); exit.setText(LayoutExample.getResourceString("Exit")); exit.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { shell.close(); } }); editItem.setMenu(menu); shell.pack(); shell.setSize(400, 500); shell.open(); Display display = shell.getDisplay(); while (!shell.isDisposed()) if (!display.readAndDispatch()) display.sleep(); } }); }