<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FSWT%2FClipboard</id>
		<title>Java Tutorial/SWT/Clipboard - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FSWT%2FClipboard"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/Clipboard&amp;action=history"/>
		<updated>2026-04-09T02:28:24Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/SWT/Clipboard&amp;diff=3039&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/Clipboard&amp;diff=3039&amp;oldid=prev"/>
				<updated>2010-05-31T17:44:26Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 17:44, 31 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/SWT/Clipboard&amp;diff=3040&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/Clipboard&amp;diff=3040&amp;oldid=prev"/>
				<updated>2010-05-31T15:20:04Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==  Clipboard: enable/disable menu depending on clipboard content availability ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2004 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
/*&lt;br /&gt;
 * Clipboard example snippet: enable/disable menu depending on clipboard content availability&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 * &lt;br /&gt;
 * @since 3.0&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.dnd.Clipboard;&lt;br /&gt;
import org.eclipse.swt.dnd.TextTransfer;&lt;br /&gt;
import org.eclipse.swt.dnd.Transfer;&lt;br /&gt;
import org.eclipse.swt.dnd.TransferData;&lt;br /&gt;
import org.eclipse.swt.events.MenuAdapter;&lt;br /&gt;
import org.eclipse.swt.events.MenuEvent;&lt;br /&gt;
import org.eclipse.swt.events.SelectionAdapter;&lt;br /&gt;
import org.eclipse.swt.events.SelectionEvent;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Menu;&lt;br /&gt;
import org.eclipse.swt.widgets.MenuItem;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Text;&lt;br /&gt;
public class MenuDisableEnableClipBoard {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Clipboard cb = new Clipboard(display);&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    final Text text = new Text(shell, SWT.BORDER | SWT.MULTI | SWT.WRAP);&lt;br /&gt;
    Menu menu = new Menu(shell, SWT.POP_UP);&lt;br /&gt;
    final MenuItem copyItem = new MenuItem(menu, SWT.PUSH);&lt;br /&gt;
    copyItem.setText(&amp;quot;Copy&amp;quot;);&lt;br /&gt;
    copyItem.addSelectionListener(new SelectionAdapter() {&lt;br /&gt;
      public void widgetSelected(SelectionEvent e) {&lt;br /&gt;
        String selection = text.getSelectionText();&lt;br /&gt;
        if (selection.length() == 0)&lt;br /&gt;
          return;&lt;br /&gt;
        Object[] data = new Object[] { selection };&lt;br /&gt;
        Transfer[] types = new Transfer[] { TextTransfer.getInstance() };&lt;br /&gt;
        cb.setContents(data, types);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    final MenuItem pasteItem = new MenuItem(menu, SWT.PUSH);&lt;br /&gt;
    pasteItem.setText(&amp;quot;Paste&amp;quot;);&lt;br /&gt;
    pasteItem.addSelectionListener(new SelectionAdapter() {&lt;br /&gt;
      public void widgetSelected(SelectionEvent e) {&lt;br /&gt;
        String string = (String) (cb.getContents(TextTransfer.getInstance()));&lt;br /&gt;
        if (string != null)&lt;br /&gt;
          text.insert(string);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    menu.addMenuListener(new MenuAdapter() {&lt;br /&gt;
      public void menuShown(MenuEvent e) {&lt;br /&gt;
        // is copy valid?&lt;br /&gt;
        String selection = text.getSelectionText();&lt;br /&gt;
        copyItem.setEnabled(selection.length() &amp;gt; 0);&lt;br /&gt;
        // is paste valid?&lt;br /&gt;
        TransferData[] available = cb.getAvailableTypes();&lt;br /&gt;
        boolean enabled = false;&lt;br /&gt;
        for (int i = 0; i &amp;lt; available.length; i++) {&lt;br /&gt;
          if (TextTransfer.getInstance().isSupportedType(available[i])) {&lt;br /&gt;
            enabled = true;&lt;br /&gt;
            break;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        pasteItem.setEnabled(enabled);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    text.setMenu(menu);&lt;br /&gt;
    shell.setSize(200, 200);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    cb.dispose();&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Using ClipBoard to copy and paste ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.dnd.Clipboard;&lt;br /&gt;
import org.eclipse.swt.dnd.TextTransfer;&lt;br /&gt;
import org.eclipse.swt.dnd.Transfer;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Text;&lt;br /&gt;
public class ClipBoardCopyPaster {&lt;br /&gt;
public static void main( String[] args) {&lt;br /&gt;
  Display display = new Display ();&lt;br /&gt;
  final Clipboard cb = new Clipboard(display);&lt;br /&gt;
  final Shell shell = new Shell (display);&lt;br /&gt;
  final Text text = new Text(shell, SWT.BORDER | SWT.SINGLE);&lt;br /&gt;
  text.setBounds(5,5,100,20);&lt;br /&gt;
  &lt;br /&gt;
  Button copy = new Button(shell, SWT.PUSH);&lt;br /&gt;
  copy.setBounds(5,50,100,20);&lt;br /&gt;
  copy.setText(&amp;quot;Copy&amp;quot;);&lt;br /&gt;
  copy.addListener (SWT.Selection, new Listener () {&lt;br /&gt;
    public void handleEvent (Event e) {&lt;br /&gt;
      String textData = text.getSelectionText();&lt;br /&gt;
      if (textData.length() &amp;gt; 0) {&lt;br /&gt;
        TextTransfer textTransfer = TextTransfer.getInstance();&lt;br /&gt;
        cb.setContents(new Object[]{textData}, new Transfer[]{textTransfer});&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  });&lt;br /&gt;
  &lt;br /&gt;
  Button paste = new Button(shell, SWT.PUSH);&lt;br /&gt;
  paste.setBounds(5,90,100,20);&lt;br /&gt;
  paste.setText(&amp;quot;Paste&amp;quot;);&lt;br /&gt;
  paste.addListener (SWT.Selection, new Listener () {&lt;br /&gt;
    public void handleEvent (Event e) {&lt;br /&gt;
      TextTransfer transfer = TextTransfer.getInstance();&lt;br /&gt;
      String data = (String)cb.getContents(transfer);&lt;br /&gt;
      if (data != null) {&lt;br /&gt;
        text.insert(data);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  });&lt;br /&gt;
  &lt;br /&gt;
  shell.setSize(200, 200);&lt;br /&gt;
  shell.open();&lt;br /&gt;
  while (!shell.isDisposed ()) {&lt;br /&gt;
    if (!display.readAndDispatch ()) display.sleep ();&lt;br /&gt;
  }&lt;br /&gt;
  cb.dispose();&lt;br /&gt;
  display.dispose();&lt;br /&gt;
}&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>