private static void makeSureSystemClipboardContainsString(
Clipboard sys, NbClipboard clip
) throws InterruptedException {
final CountDownLatch wait = new CountDownLatch(1);
class FL implements FlavorListener {
@Override
public void flavorsChanged(FlavorEvent e) {
wait.countDown();
}
}
FL fl = new FL();
sys.addFlavorListener(fl);
StringSelection ss = new StringSelection("empty");
clip.setContents(ss, ss);
wait.await();
}
java类java.awt.datatransfer.FlavorEvent的实例源码
NbClipboardTimeoutTest.java 文件源码
项目:incubator-netbeans
阅读 22
收藏 0
点赞 0
评论 0
SunClipboard.java 文件源码
项目:openjdk-jdk10
阅读 28
收藏 0
点赞 0
评论 0
/**
* Checks change of the {@code DataFlavor}s and, if necessary,
* posts notifications on {@code FlavorEvent}s to the
* AppContexts' EDTs.
* The parameter {@code formats} is null iff we have just
* failed to get formats available on the clipboard.
*
* @param formats data formats that have just been retrieved from
* this clipboard
*/
protected final void checkChange(final long[] formats) {
if (Arrays.equals(formats, currentFormats)) {
// we've been able to successfully get available on the clipboard
// DataFlavors this and previous time and they are coincident;
// don't notify
return;
}
currentFormats = formats;
for (final AppContext appContext : AppContext.getAppContexts()) {
if (appContext == null || appContext.isDisposed()) {
continue;
}
Set<FlavorListener> flavorListeners = getFlavorListeners(appContext);
if (flavorListeners != null) {
for (FlavorListener listener : flavorListeners) {
if (listener != null) {
PeerEvent peerEvent = new PeerEvent(this,
() -> listener.flavorsChanged(new FlavorEvent(SunClipboard.this)),
PeerEvent.PRIORITY_EVENT);
SunToolkit.postEvent(appContext, peerEvent);
}
}
}
}
}
GUIClipboard.java 文件源码
项目:Prism-gsoc16
阅读 21
收藏 0
点赞 0
评论 0
/** Creates a new instance of GUIClipboard */
public GUIClipboard(GUIPrism pr)
{
super(pr, false);
this.prism = pr;
initComponents();
doUndoManagerEnables();
doClipboardEnables();
/* Listen to clipboard events. */
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.addFlavorListener(new FlavorListener() {
public void flavorsChanged(FlavorEvent e) {
doClipboardEnables();
}
});
}
NbClipboard.java 文件源码
项目:incubator-netbeans
阅读 25
收藏 0
点赞 0
评论 0
final void fireChange() {
Boolean prev = FIRING.get();
try {
FIRING.set(true);
FlavorEvent e = new FlavorEvent(this);
fireClipboardChange();
for (FlavorListener l : super.getFlavorListeners()) {
l.flavorsChanged(e);
}
} finally {
FIRING.set(prev);
}
}
ExplorerPanelTest.java 文件源码
项目:incubator-netbeans
阅读 20
收藏 0
点赞 0
评论 0
@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);
}
}
SunClipboard.java 文件源码
项目:openjdk9
阅读 30
收藏 0
点赞 0
评论 0
/**
* Checks change of the {@code DataFlavor}s and, if necessary,
* posts notifications on {@code FlavorEvent}s to the
* AppContexts' EDTs.
* The parameter {@code formats} is null iff we have just
* failed to get formats available on the clipboard.
*
* @param formats data formats that have just been retrieved from
* this clipboard
*/
protected final void checkChange(final long[] formats) {
if (Arrays.equals(formats, currentFormats)) {
// we've been able to successfully get available on the clipboard
// DataFlavors this and previous time and they are coincident;
// don't notify
return;
}
currentFormats = formats;
for (final AppContext appContext : AppContext.getAppContexts()) {
if (appContext == null || appContext.isDisposed()) {
continue;
}
Set<FlavorListener> flavorListeners = getFlavorListeners(appContext);
if (flavorListeners != null) {
for (FlavorListener listener : flavorListeners) {
if (listener != null) {
PeerEvent peerEvent = new PeerEvent(this,
() -> listener.flavorsChanged(new FlavorEvent(SunClipboard.this)),
PeerEvent.PRIORITY_EVENT);
SunToolkit.postEvent(appContext, peerEvent);
}
}
}
}
}
TextActions.java 文件源码
项目:confluence.keygen
阅读 23
收藏 0
点赞 0
评论 0
public void flavorsChanged(FlavorEvent e)
/* 92: */ {
/* 93:106 */ JComponent c = TextActions.this.getFocusOwner();
/* 94:107 */ if ((c instanceof JTextComponent)) {
/* 95:108 */ TextActions.this.updateTextActions((JTextComponent)c);
/* 96: */ }
/* 97: */ }
PasteButton.java 文件源码
项目:opendocs
阅读 22
收藏 0
点赞 0
评论 0
@Override
public void flavorsChanged(final FlavorEvent e) {
try {
final Transferable transfer = clipboard.getContents(null);
final DataFlavor[] transferDataFlavors = transfer.getTransferDataFlavors();
for (final DataFlavor dataFlavor : transferDataFlavors) {
if (dataFlavor.equals(DataFlavor.stringFlavor)) {
this.setEnabled(true);
return;
}
}
} catch (final Exception e1) {
}
this.setEnabled(false);
}
ClipboardListener.java 文件源码
项目:Clipshare
阅读 21
收藏 0
点赞 0
评论 0
@Override
public void flavorsChanged(FlavorEvent flavorEvent)
{
System.out.println("Clipboard update detected (Flavor)");
int[] currentRevision = ClipboardManager.getInstance().getCurrentRevision();
regainOwnershipAndBroadcast(currentRevision);
}
NbClipboard.java 文件源码
项目:incubator-netbeans
阅读 21
收藏 0
点赞 0
评论 0
@Override
public void flavorsChanged(FlavorEvent e) {
if( !anyWindowIsActivated )
return; //#227236 - don't react to system clipboard changes when the IDE window is in the background
fireChange();
}
ExplorerActionsImpl.java 文件源码
项目:incubator-netbeans
阅读 23
收藏 0
点赞 0
评论 0
@Override
public void flavorsChanged(FlavorEvent ev) {
schedule();
}
ClipboardHandler.java 文件源码
项目:widgetfx
阅读 26
收藏 0
点赞 0
评论 0
@Override
public void flavorsChanged(FlavorEvent e) {
//System.out.println("----------> flavors changed");
this.clipboardUpdated = true;
}
MMDGraphEditor.java 文件源码
项目:netbeans-mmd-plugin
阅读 24
收藏 0
点赞 0
评论 0
@Override
public void flavorsChanged(@Nonnull final FlavorEvent e) {
processClipboardChange((Clipboard) e.getSource());
}
MainFrame.java 文件源码
项目:ExtendedHodoku
阅读 27
收藏 0
点赞 0
评论 0
@Override
public void flavorsChanged(FlavorEvent e) {
adjustPasteMenuItem();
}
PasteAction.java 文件源码
项目:JRLib
阅读 23
收藏 0
点赞 0
评论 0
@Override
public void flavorsChanged(FlavorEvent e) {
if(reactToClipboard)
PasteAction.this.contextChanged();
}