org.eclipse.swt.dnd.Clipboard.setContents()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中org.eclipse.swt.dnd.Clipboard.setContents()方法的一些代码示例,展示了Clipboard.setContents()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Clipboard.setContents()方法的具体详情如下:
包路径:org.eclipse.swt.dnd.Clipboard
类名称:Clipboard
方法名:setContents

Clipboard.setContents介绍

[英]Place data of the specified type on the system clipboard. More than one type of data can be placed on the system clipboard at the same time. Setting the data clears any previous data from the system clipboard, regardless of type.

NOTE: On some platforms, the data is immediately copied to the system clipboard but on other platforms it is provided upon request. As a result, if the application modifies the data object it has set on the clipboard, that modification may or may not be available when the data is subsequently requested.

The following snippet shows text and RTF text being set on the copy/paste clipboard:
<<$0$>>
[中]将指定类型的数据放在系统剪贴板上。可以同时在系统剪贴板上放置多种类型的数据。设置数据将清除系统剪贴板中以前的任何数据,而不考虑类型。
注意:在某些平台上,数据会立即复制到系统剪贴板,但在其他平台上,数据会根据要求提供。因此,如果应用程序修改它在剪贴板上设置的数据对象,则在随后请求数据时,该修改可能可用,也可能不可用。
以下代码段显示了在复制/粘贴剪贴板上设置的文本和RTF文本:
<<$0$>>

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

public void toClipboard( String cliptext ) {
 if ( cliptext == null ) {
  return;
 }
 getNewClipboard();
 TextTransfer tran = TextTransfer.getInstance();
 clipboard.setContents( new String[] { cliptext }, new Transfer[] { tran } );
}

代码示例来源:origin: pentaho/pentaho-kettle

private void clipSelected() {
 if ( clipboard != null ) {
  clipboard.dispose();
  clipboard = null;
 }
 clipboard = new Clipboard( getDisplay() );
 TextTransfer tran = TextTransfer.getInstance();
 String clip = getSelectedText();
 if ( clip == null ) {
  return;
 }
 clipboard.setContents( new String[]{ clip }, new Transfer[]{ tran } );
}

代码示例来源:origin: pentaho/pentaho-kettle

@Override public void keyPressed( KeyEvent keyEvent ) {
 int state = keyEvent.stateMask, key = keyEvent.keyCode;
 boolean copyContent = state == SWT.CTRL && key == SWT.F6,
   arrowNavigation = ( state == SWT.COMMAND || state == SWT.ALT )
     && ( key == SWT.ARROW_LEFT || key == SWT.ARROW_RIGHT ),
   backslashNavigation = ( state == SWT.SHIFT && key == SWT.BS ),
   reloadContent = state == SWT.CTRL && ( key == SWT.F5 || key == 114 /* r key */ ) || key == SWT.F5,
   zoomContent = state == SWT.CTRL && ( key == SWT.KEYPAD_ADD || key == SWT.KEYPAD_SUBTRACT
     || key == 61 /* + key */ || key == 45 /* - key */ );
 if ( copyContent ) {
  Browser thisBrowser = (Browser) keyEvent.getSource();
  Clipboard clipboard = new Clipboard( thisBrowser.getDisplay() );
  clipboard.setContents( new String[] { lastNavigateURL }, new Transfer[] { TextTransfer.getInstance() } );
  clipboard.dispose();
 } else if ( arrowNavigation || backslashNavigation || reloadContent || zoomContent ) {
  keyEvent.doit = false;
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

public void copyTransformationImage( TransMeta transMeta ) {
 TransGraph transGraph = delegates.trans.findTransGraphOfTransformation( transMeta );
 if ( transGraph == null ) {
  return;
 }
 Clipboard clipboard = GUIResource.getInstance().getNewClipboard();
 Point area = transMeta.getMaximum();
 Image image = transGraph.getTransformationImage( Display.getCurrent(), area.x, area.y, 1.0f );
 clipboard.setContents(
  new Object[] { image.getImageData() }, new Transfer[] { ImageTransfer.getInstance() } );
}

代码示例来源:origin: org.eclipse/org.eclipse.ui.workbench.texteditor

/**
 * Appends the given string to this clipboard.
 *
 * @param deltaString the string to append
 */
public void append(String deltaString) {
  fBuffer.append(deltaString);
  String string= fBuffer.toString();
  Transfer[] dataTypes= new Transfer[] { TextTransfer.getInstance() };
  Object[] data= new Object[] { string };
  fClipboard.setContents(data, dataTypes);
}

代码示例来源:origin: org.eclipse.ui.views/log

/**
 * Copies selected element to clipboard.
 */
private void copyToClipboard(ISelection selection) {
  String textVersion = selectionToString(selection);
  if ((textVersion != null) && (textVersion.trim().length() > 0)) {
    // set the clipboard contents
    fClipboard.setContents(new Object[] {textVersion}, new Transfer[] {TextTransfer.getInstance()});
  }
}

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void mouseDown(MouseEvent arg0) {
    String hash_str = hash.getText();
    if(hash_str != null && hash_str.length() != 0)
      new Clipboard(display).setContents(new Object[] {hash_str.replaceAll(" ","")}, new Transfer[] {TextTransfer.getInstance()});
  }
});

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void handleEvent(Event event) {
new Clipboard(Display.getCurrent()).setContents(
        new Object[] { txtFP.getText() },
        new Transfer[] { TextTransfer.getInstance() });
  }
});

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
public void mouseDoubleClick(MouseEvent arg0) {
  String announce = trackerUrlValue.getText();
  if (announce != null && announce.length() != 0) {
    new Clipboard(display).setContents(new Object[] {
      announce
    }, new Transfer[] {
      TextTransfer.getInstance()
    });
  }
}

代码示例来源:origin: org.codehaus.openxma/xmartclient

protected void handleCopy() {
  // Context menu selected: copy cell value to clipboard
  if (copyMenuClipboardText_ != null && copyMenuClipboardText_.length()>0) {
    Display display = table_.getShell().getDisplay();
    Clipboard clipboard = new Clipboard(display);
    clipboard.setContents(new String[] {copyMenuClipboardText_}, new Transfer[] {TextTransfer.getInstance()});
    clipboard.dispose();
  }
}

代码示例来源:origin: BiglySoftware/BiglyBT

protected void
writeToClipboard(
  String    str )
{
   new Clipboard(Utils.getDisplay()).setContents(
       new Object[] {str },
       new Transfer[] {TextTransfer.getInstance()});
}

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void
  widgetSelected(
      SelectionEvent arg0)
  {
    new Clipboard(menu.getDisplay()).setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()});
  }
});

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void
  widgetSelected(
    SelectionEvent arg0)
  {
    if ( !composite.isDisposed() && text != null && text.length() > 0 ){
      new Clipboard(composite.getDisplay()).setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()});
    }
  }
});

代码示例来源:origin: org.eclipse.egit/ui

public void run() {
    TextTransfer plainTextTransfer = TextTransfer.getInstance();
    Clipboard clipboard = new Clipboard(getShell().getDisplay());
    clipboard.setContents(new String[] { content },
        new Transfer[] { plainTextTransfer });
    clipboard.dispose();
  }
});

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

@Override
  public void widgetSelected(SelectionEvent e) {
    String text = fMessageLabel.getText();
    if (text != null && text.length() > 0) {
      text = LegacyActionTools.removeMnemonics(text);
      Clipboard cp = new Clipboard(e.display);
      cp.setContents(new Object[] { text },
          new Transfer[] { TextTransfer.getInstance() });
      cp.dispose();
    }
  }
});

代码示例来源:origin: org.eclipse/org.eclipse.ajdt.ui

/**
 * Copy the contents of the statuses to the clipboard.
 */
private void copyToClipboard() {
  if (clipboard != null)
    clipboard.dispose();
  clipboard = new Clipboard(list.getDisplay());
  clipboard.setContents(new Object[] { longMessage },
      new Transfer[] { TextTransfer.getInstance() });
}

代码示例来源:origin: org.eclipse.scout.sdk.s2e/org.eclipse.scout.sdk.s2e.nls

@Override
public void run() {
 Clipboard clipboard = new Clipboard(m_display);
 String rtfData = "{\\rtf1\\b\\i " + m_toCopy + "}"; // formatted as bold and italic
 TextTransfer textTransfer = TextTransfer.getInstance();
 RTFTransfer rtfTransfer = RTFTransfer.getInstance();
 Transfer[] transfers = new Transfer[]{textTransfer, rtfTransfer};
 Object[] data = new Object[]{m_toCopy, rtfData};
 clipboard.setContents(data, transfers);
 clipboard.dispose();
}

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void
  widgetSelected(
      SelectionEvent arg0)
  {
    new Clipboard(menu.getDisplay()).setContents(new Object[] { provider.getText()}, new Transfer[] {TextTransfer.getInstance()});
  }
});

代码示例来源:origin: org.eclipse.equinox.p2/ui

public void copyToClipboard(Control activeControl) {
  String text = getClipboardText(activeControl);
  if (text.length() == 0)
    return;
  Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());
  clipboard.setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()});
  clipboard.dispose();
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

private void copyToClipboard() {
  Clipboard clipboard = null;
  try {
    clipboard = new Clipboard(text.getDisplay());
    clipboard.setContents(new Object[] { text.getSelectionText() },
        new Transfer[] { TextTransfer.getInstance() });
  } finally {
    if (clipboard != null) {
      clipboard.dispose();
    }
  }
}

相关文章