Java 类java.awt.datatransfer.ClipboardOwner 实例源码
项目:incubator-netbeans
文件:NbClipboard.java
private synchronized void superSetContents(Transferable t, ClipboardOwner o) {
if (this.contents != null) {
transferableOwnershipLost(this.contents);
}
final ClipboardOwner oldOwner = this.owner;
final Transferable oldContents = this.contents;
this.owner = o;
this.contents = t;
if (oldOwner != null && oldOwner != owner) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
oldOwner.lostOwnership(NbClipboard.this, oldContents);
}
});
}
}
项目:incubator-netbeans
文件:PasteAction.java
public void actionPerformed(ActionEvent ev) {
try {
Transferable trans = t.paste();
Clipboard clipboard = getClipboard();
if (trans != null) {
ClipboardOwner owner = (trans instanceof ClipboardOwner) ? (ClipboardOwner) trans
: new StringSelection(""); // NOI18N
clipboard.setContents(trans, owner);
}
} catch (UserCancelException exc) {
// ignore - user just pressed cancel in some dialog....
} catch (IOException e) {
Exceptions.printStackTrace(e);
} finally {
EventQueue.invokeLater(this);
}
}
项目:DecompiledMinecraft
文件:GuiScreen.java
/**
* Stores the given string in the system clipboard
*/
public static void setClipboardString(String copyText)
{
if (!StringUtils.isEmpty(copyText))
{
try
{
StringSelection stringselection = new StringSelection(copyText);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringselection, (ClipboardOwner)null);
}
catch (Exception var2)
{
;
}
}
}
项目:BaseClient
文件:GuiScreen.java
/**
* Stores the given string in the system clipboard
*/
public static void setClipboardString(String copyText)
{
if (!StringUtils.isEmpty(copyText))
{
try
{
StringSelection stringselection = new StringSelection(copyText);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringselection, (ClipboardOwner)null);
}
catch (Exception var2)
{
;
}
}
}
项目:BaseClient
文件:GuiScreen.java
/**
* Stores the given string in the system clipboard
*/
public static void setClipboardString(String copyText)
{
if (!StringUtils.isEmpty(copyText))
{
try
{
StringSelection stringselection = new StringSelection(copyText);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringselection, (ClipboardOwner)null);
}
catch (Exception var2)
{
;
}
}
}
项目:jdk8u-jdk
文件:SunClipboard.java
protected void lostOwnershipNow(final AppContext disposedContext) {
final SunClipboard sunClipboard = SunClipboard.this;
ClipboardOwner owner = null;
Transferable contents = null;
synchronized (sunClipboard) {
final AppContext context = sunClipboard.contentsContext;
if (context == null) {
return;
}
if (disposedContext == null || context == disposedContext) {
owner = sunClipboard.owner;
contents = sunClipboard.contents;
sunClipboard.contentsContext = null;
sunClipboard.owner = null;
sunClipboard.contents = null;
sunClipboard.clearNativeContext();
context.removePropertyChangeListener
(AppContext.DISPOSED_PROPERTY_NAME, sunClipboard);
} else {
return;
}
}
if (owner != null) {
owner.lostOwnership(sunClipboard, contents);
}
}
项目:openjdk-jdk10
文件:SunClipboard.java
public synchronized void setContents(Transferable contents,
ClipboardOwner owner) {
// 4378007 : Toolkit.getSystemClipboard().setContents(null, null)
// should throw NPE
if (contents == null) {
throw new NullPointerException("contents");
}
initContext();
final ClipboardOwner oldOwner = this.owner;
final Transferable oldContents = this.contents;
try {
this.owner = owner;
this.contents = new TransferableProxy(contents, true);
setContentsNative(contents);
} finally {
if (oldOwner != null && oldOwner != owner) {
EventQueue.invokeLater(() -> oldOwner.lostOwnership(SunClipboard.this, oldContents));
}
}
}
项目:openjdk-jdk10
文件:SunClipboard.java
protected void lostOwnershipNow(final AppContext disposedContext) {
final SunClipboard sunClipboard = SunClipboard.this;
ClipboardOwner owner = null;
Transferable contents = null;
synchronized (sunClipboard) {
final AppContext context = sunClipboard.contentsContext;
if (context == null) {
return;
}
if (disposedContext == null || context == disposedContext) {
owner = sunClipboard.owner;
contents = sunClipboard.contents;
sunClipboard.contentsContext = null;
sunClipboard.owner = null;
sunClipboard.contents = null;
sunClipboard.clearNativeContext();
context.removePropertyChangeListener
(AppContext.DISPOSED_PROPERTY_NAME, sunClipboard);
} else {
return;
}
}
if (owner != null) {
owner.lostOwnership(sunClipboard, contents);
}
}
项目:openjdk-jdk10
文件:GetContentsInterruptedTest.java
public void execute() {
System.out.println("Hello world");
final ClipboardOwner clipboardOwner = new ClipboardOwner() {
public void lostOwnership(Clipboard clipboard, Transferable contents) {
System.exit(0);
}
};
clipboard.setContents(transferable, clipboardOwner);
synchronized (o) {
try {
o.wait();
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
项目:Backmemed
文件:GuiScreen.java
/**
* Stores the given string in the system clipboard
*/
public static void setClipboardString(String copyText)
{
if (!StringUtils.isEmpty(copyText))
{
try
{
StringSelection stringselection = new StringSelection(copyText);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringselection, (ClipboardOwner)null);
}
catch (Exception var2)
{
;
}
}
}
项目:CustomWorldGen
文件:GuiScreen.java
/**
* Stores the given string in the system clipboard
*/
public static void setClipboardString(String copyText)
{
if (!StringUtils.isEmpty(copyText))
{
try
{
StringSelection stringselection = new StringSelection(copyText);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringselection, (ClipboardOwner)null);
}
catch (Exception var2)
{
;
}
}
}
项目:openjdk9
文件:SunClipboard.java
public synchronized void setContents(Transferable contents,
ClipboardOwner owner) {
// 4378007 : Toolkit.getSystemClipboard().setContents(null, null)
// should throw NPE
if (contents == null) {
throw new NullPointerException("contents");
}
initContext();
final ClipboardOwner oldOwner = this.owner;
final Transferable oldContents = this.contents;
try {
this.owner = owner;
this.contents = new TransferableProxy(contents, true);
setContentsNative(contents);
} finally {
if (oldOwner != null && oldOwner != owner) {
EventQueue.invokeLater(() -> oldOwner.lostOwnership(SunClipboard.this, oldContents));
}
}
}
项目:openjdk9
文件:GetContentsInterruptedTest.java
public void execute() {
System.out.println("Hello world");
final ClipboardOwner clipboardOwner = new ClipboardOwner() {
public void lostOwnership(Clipboard clipboard, Transferable contents) {
System.exit(0);
}
};
clipboard.setContents(transferable, clipboardOwner);
synchronized (o) {
try {
o.wait();
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
项目:netbeansplugins
文件:ExportDataAction.java
@Override
public void performAction() {
final WordCountTopComponent win = WordCountTopComponent.findInstance();
if (win == null) {
return ;
}
// the wordcount table model
final WordCountTableModel wctm = win.getWordCountTableModel();
if (wctm == null) {
return ;
}
// format the wordcount table model
final StringBuffer sb = new StringBuffer();
buildHeader1( wctm, sb );
buildContentInfo( win, sb );
buildContentWc( wctm, sb );
// copy sb to the clipboard
final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
final StringSelection stringSelection = new StringSelection(sb.toString());
final ClipboardOwner owner = stringSelection;
clipboard.setContents(stringSelection, owner );
}
项目:Resilience-Client-Source
文件:GuiScreenBackup.java
private void func_146821_q()
{
Session var1 = this.mc.getSession();
McoClient var2 = new McoClient(var1.getSessionID(), var1.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy());
try
{
String var3 = var2.func_148708_h(this.field_146846_h);
Clipboard var4 = Toolkit.getDefaultToolkit().getSystemClipboard();
var4.setContents(new StringSelection(var3), (ClipboardOwner)null);
this.func_146823_a(var3);
}
catch (ExceptionMcoService var5)
{
logger.error("Couldn\'t download world data");
}
}
项目:Resilience-Client-Source
文件:GuiScreenSubscription.java
protected void actionPerformed(GuiButton p_146284_1_)
{
if (p_146284_1_.enabled)
{
if (p_146284_1_.id == 0)
{
this.mc.displayGuiScreen(this.field_146780_f);
}
else if (p_146284_1_.id == 1)
{
String var2 = "https://account.mojang.com/buy/realms?wid=" + this.field_146781_g.field_148812_a + "?pid=" + this.func_146777_g();
Clipboard var3 = Toolkit.getDefaultToolkit().getSystemClipboard();
var3.setContents(new StringSelection(var2), (ClipboardOwner)null);
this.func_146779_a(var2);
}
}
}
项目:ExpandedRailsMod
文件:GuiScreen.java
/**
* Stores the given string in the system clipboard
*/
public static void setClipboardString(String copyText)
{
if (!StringUtils.isEmpty(copyText))
{
try
{
StringSelection stringselection = new StringSelection(copyText);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringselection, (ClipboardOwner)null);
}
catch (Exception var2)
{
;
}
}
}
项目:Testy
文件:MultiThreadClipboardUtils.java
/***
* Waits until the system clipboard is not being used by another WebDriver instance,
* then populates the system clipboard with the value previously stored for the current WebDriver instance
* and finally sends the CTRL + v command to the specified locator
* <p>
* {@link #copyString(String) copyString} method should have been called before
*
* @param locator WebLocator where the value from clipboard corresponding to the current WebDriver instance should be pasted
*/
public static void pasteString(WebLocator locator) {
waitForUnlockedClipboard();
lockClipboard();
String value = clipboardContents.get(((RemoteWebDriver) WebDriverConfig.getDriver()).getSessionId().toString());
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(value),
new ClipboardOwner() {
@Override
public void lostOwnership(final java.awt.datatransfer.Clipboard clipboard, final Transferable contents) {
// do nothing
}
});
try {
locator.sendKeys(Keys.CONTROL, "v");
} catch (Throwable throwable) {
// Making sure clipboard would not unexpectedly remain locked
unlockClipboard();
}
unlockClipboard();
}
项目:AMIDST
文件:AmidstMenu.java
private CopySeedMenuItem() {
super("Copy Seed to Clipboard");
setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK));
addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
StringSelection stringSelection = new StringSelection(Options.instance.seed + "");
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, new ClipboardOwner() {
@Override
public void lostOwnership(Clipboard arg0, Transferable arg1) {
// TODO Auto-generated method stub
}
});
}
});
}
项目:incubator-netbeans
文件:NbClipboardTest.java
@Override
public synchronized void setContents(Transferable contents, ClipboardOwner owner) {
setContentsCounter++;
if( pretendToBeBusy ) {
pretendToBeBusy = false;
throw new IllegalStateException();
}
super.setContents(contents, owner);
}
项目:incubator-netbeans
文件:ExplorerPanelTest.java
@Override
public void setContents (Transferable t, ClipboardOwner o) {
super.setContents (t, o);
fireClipboardChange ();
FlavorEvent ev = new FlavorEvent(this);
for (FlavorListener flavorListener : getFlavorListeners()) {
flavorListener.flavorsChanged(ev);
}
}
项目:OpenJSharp
文件:SunClipboard.java
public synchronized void setContents(Transferable contents,
ClipboardOwner owner) {
// 4378007 : Toolkit.getSystemClipboard().setContents(null, null)
// should throw NPE
if (contents == null) {
throw new NullPointerException("contents");
}
initContext();
final ClipboardOwner oldOwner = this.owner;
final Transferable oldContents = this.contents;
try {
this.owner = owner;
this.contents = new TransferableProxy(contents, true);
setContentsNative(contents);
} finally {
if (oldOwner != null && oldOwner != owner) {
EventQueue.invokeLater(new Runnable() {
public void run() {
oldOwner.lostOwnership(SunClipboard.this, oldContents);
}
});
}
}
}
项目:jdk8u-jdk
文件:SunClipboard.java
public synchronized void setContents(Transferable contents,
ClipboardOwner owner) {
// 4378007 : Toolkit.getSystemClipboard().setContents(null, null)
// should throw NPE
if (contents == null) {
throw new NullPointerException("contents");
}
initContext();
final ClipboardOwner oldOwner = this.owner;
final Transferable oldContents = this.contents;
try {
this.owner = owner;
this.contents = new TransferableProxy(contents, true);
setContentsNative(contents);
} finally {
if (oldOwner != null && oldOwner != owner) {
EventQueue.invokeLater(new Runnable() {
public void run() {
oldOwner.lostOwnership(SunClipboard.this, oldContents);
}
});
}
}
}
项目:openjdk9
文件:SunClipboard.java
protected void lostOwnershipNow(final AppContext disposedContext) {
final SunClipboard sunClipboard = SunClipboard.this;
ClipboardOwner owner = null;
Transferable contents = null;
synchronized (sunClipboard) {
final AppContext context = sunClipboard.contentsContext;
if (context == null) {
return;
}
if (disposedContext == null || context == disposedContext) {
owner = sunClipboard.owner;
contents = sunClipboard.contents;
sunClipboard.contentsContext = null;
sunClipboard.owner = null;
sunClipboard.contents = null;
sunClipboard.clearNativeContext();
context.removePropertyChangeListener
(AppContext.DISPOSED_PROPERTY_NAME, sunClipboard);
} else {
return;
}
}
if (owner != null) {
owner.lostOwnership(sunClipboard, contents);
}
}
项目:4Space-5
文件:GuiScreen.java
public static void setClipboardString(String p_146275_0_)
{
try
{
StringSelection stringselection = new StringSelection(p_146275_0_);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringselection, (ClipboardOwner)null);
}
catch (Exception exception) {}
}
项目:jdk8u_jdk
文件:SunClipboard.java
public synchronized void setContents(Transferable contents,
ClipboardOwner owner) {
// 4378007 : Toolkit.getSystemClipboard().setContents(null, null)
// should throw NPE
if (contents == null) {
throw new NullPointerException("contents");
}
initContext();
final ClipboardOwner oldOwner = this.owner;
final Transferable oldContents = this.contents;
try {
this.owner = owner;
this.contents = new TransferableProxy(contents, true);
setContentsNative(contents);
} finally {
if (oldOwner != null && oldOwner != owner) {
EventQueue.invokeLater(new Runnable() {
public void run() {
oldOwner.lostOwnership(SunClipboard.this, oldContents);
}
});
}
}
}
项目:jdk8u_jdk
文件:SunClipboard.java
protected void lostOwnershipNow(final AppContext disposedContext) {
final SunClipboard sunClipboard = SunClipboard.this;
ClipboardOwner owner = null;
Transferable contents = null;
synchronized (sunClipboard) {
final AppContext context = sunClipboard.contentsContext;
if (context == null) {
return;
}
if (disposedContext == null || context == disposedContext) {
owner = sunClipboard.owner;
contents = sunClipboard.contents;
sunClipboard.contentsContext = null;
sunClipboard.owner = null;
sunClipboard.contents = null;
sunClipboard.clearNativeContext();
context.removePropertyChangeListener
(AppContext.DISPOSED_PROPERTY_NAME, sunClipboard);
} else {
return;
}
}
if (owner != null) {
owner.lostOwnership(sunClipboard, contents);
}
}
项目:runelite
文件:GameEngine.java
@ObfuscatedName("g")
@ObfuscatedSignature(
signature = "(Ljava/lang/String;I)V",
garbageValue = "-1362299099"
)
protected void method884(String var1) {
this.clipboard.setContents(new StringSelection(var1), (ClipboardOwner)null);
}
项目:lookaside_java-1.8.0-openjdk
文件:SunClipboard.java
public synchronized void setContents(Transferable contents,
ClipboardOwner owner) {
// 4378007 : Toolkit.getSystemClipboard().setContents(null, null)
// should throw NPE
if (contents == null) {
throw new NullPointerException("contents");
}
initContext();
final ClipboardOwner oldOwner = this.owner;
final Transferable oldContents = this.contents;
try {
this.owner = owner;
this.contents = new TransferableProxy(contents, true);
setContentsNative(contents);
} finally {
if (oldOwner != null && oldOwner != owner) {
EventQueue.invokeLater(new Runnable() {
public void run() {
oldOwner.lostOwnership(SunClipboard.this, oldContents);
}
});
}
}
}
项目:lookaside_java-1.8.0-openjdk
文件:SunClipboard.java
protected void lostOwnershipNow(final AppContext disposedContext) {
final SunClipboard sunClipboard = SunClipboard.this;
ClipboardOwner owner = null;
Transferable contents = null;
synchronized (sunClipboard) {
final AppContext context = sunClipboard.contentsContext;
if (context == null) {
return;
}
if (disposedContext == null || context == disposedContext) {
owner = sunClipboard.owner;
contents = sunClipboard.contents;
sunClipboard.contentsContext = null;
sunClipboard.owner = null;
sunClipboard.contents = null;
sunClipboard.clearNativeContext();
context.removePropertyChangeListener
(AppContext.DISPOSED_PROPERTY_NAME, sunClipboard);
} else {
return;
}
}
if (owner != null) {
owner.lostOwnership(sunClipboard, contents);
}
}
项目:xdm
文件:XDMMainWindow.java
void copyFiles(DownloadListItem[] items) {
Object[] values = (Object[])null;
if(items != null) {
values = new Object[items.length];
for(int plainBuf = 0; plainBuf < items.length; ++plainBuf) {
DownloadListItem htmlBuf = items[plainBuf];
File i = new File(htmlBuf.saveto, htmlBuf.filename);
values[plainBuf] = i;
}
}
StringBuffer var8 = new StringBuffer();
StringBuffer var9 = new StringBuffer();
var9.append("<html>\n<body>\n<ul>\n");
for(int var10 = 0; var10 < values.length; ++var10) {
Object obj = values[var10];
String val = obj == null?"":obj.toString();
var8.append(val + "\n");
var9.append(" <li>" + val + "\n");
}
if(this.clipboard == null) {
this.clipboard = this.t.getSystemClipboard();
}
this.clipboard.setContents(new FileTransferHandler.FileTransferable(var8.toString(), var9.toString(), values), (ClipboardOwner)null);
}
项目:xdm
文件:XDMMainWindow.java
void copyURL(String url) {
System.out.println("Copying url " + url);
if(this.clipboard == null) {
this.clipboard = this.t.getSystemClipboard();
}
this.clipboard.setContents(new StringSelection(url), (ClipboardOwner)null);
}
项目:SMAnimator
文件:ClipboardHelper.java
public static void placeFileToClipboard(String path) {
File file = new File(path);
List listOfFiles = new ArrayList();
listOfFiles.add(file);
FileTransferable ft = new FileTransferable(listOfFiles);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ft, new ClipboardOwner() {
@Override
public void lostOwnership(Clipboard clipboard, Transferable contents) {
System.out.println("Lost ownership");
}
});
}
项目:ClipboardFileTransfer
文件:ClipboradHelperTest.java
@Test
public void writeSuccesTest() {
Clipboard clip = mock(Clipboard.class);
doNothing().when(clip).setContents(any(Transferable.class), any(ClipboardOwner.class));
ClipboradHelper helper = new ClipboradHelper(clip);
ClipboardRespons resp = helper.writeToCliboard("AAA");
assertTrue(resp.isValid());
}
项目:ClipboardFileTransfer
文件:ClipboradHelperTest.java
@Test
public void writeLockSuccesTest() {
Clipboard clip = mock(Clipboard.class);
doThrow(new IllegalStateException()).doNothing().when(clip).setContents(any(Transferable.class), any(ClipboardOwner.class));
ClipboradHelper helper = new ClipboradHelper(clip);
ClipboardRespons resp = helper.writeToCliboard("AAA");
assertTrue(resp.isValid());
}
项目:umple
文件:JNLPClipboard.java
@Override
public void setContents(Transferable contents, ClipboardOwner owner) {
try {
target.getClass().getMethod("setContents", Transferable.class).invoke(target, contents);
} catch (Exception ex) {
InternalError error = new InternalError("Failed to invoke setContents(Transferable) on "+target);
error.initCause(ex);
throw error;
}
}
项目:infobip-open-jdk-8
文件:SunClipboard.java
public synchronized void setContents(Transferable contents,
ClipboardOwner owner) {
// 4378007 : Toolkit.getSystemClipboard().setContents(null, null)
// should throw NPE
if (contents == null) {
throw new NullPointerException("contents");
}
initContext();
final ClipboardOwner oldOwner = this.owner;
final Transferable oldContents = this.contents;
try {
this.owner = owner;
this.contents = new TransferableProxy(contents, true);
setContentsNative(contents);
} finally {
if (oldOwner != null && oldOwner != owner) {
EventQueue.invokeLater(new Runnable() {
public void run() {
oldOwner.lostOwnership(SunClipboard.this, oldContents);
}
});
}
}
}
项目:jdk8u-dev-jdk
文件:SunClipboard.java
public synchronized void setContents(Transferable contents,
ClipboardOwner owner) {
// 4378007 : Toolkit.getSystemClipboard().setContents(null, null)
// should throw NPE
if (contents == null) {
throw new NullPointerException("contents");
}
initContext();
final ClipboardOwner oldOwner = this.owner;
final Transferable oldContents = this.contents;
try {
this.owner = owner;
this.contents = new TransferableProxy(contents, true);
setContentsNative(contents);
} finally {
if (oldOwner != null && oldOwner != owner) {
EventQueue.invokeLater(new Runnable() {
public void run() {
oldOwner.lostOwnership(SunClipboard.this, oldContents);
}
});
}
}
}
项目:jdk8u-dev-jdk
文件:SunClipboard.java
protected void lostOwnershipNow(final AppContext disposedContext) {
final SunClipboard sunClipboard = SunClipboard.this;
ClipboardOwner owner = null;
Transferable contents = null;
synchronized (sunClipboard) {
final AppContext context = sunClipboard.contentsContext;
if (context == null) {
return;
}
if (disposedContext == null || context == disposedContext) {
owner = sunClipboard.owner;
contents = sunClipboard.contents;
sunClipboard.contentsContext = null;
sunClipboard.owner = null;
sunClipboard.contents = null;
sunClipboard.clearNativeContext();
context.removePropertyChangeListener
(AppContext.DISPOSED_PROPERTY_NAME, sunClipboard);
} else {
return;
}
}
if (owner != null) {
owner.lostOwnership(sunClipboard, contents);
}
}
项目:Resilience-Client-Source
文件:GuiScreen.java
/**
* Stores the given string in the system clipboard
*/
public static void setClipboardString(String p_146275_0_)
{
try
{
StringSelection var1 = new StringSelection(p_146275_0_);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(var1, (ClipboardOwner)null);
}
catch (Exception var2)
{
;
}
}