Java 类java.awt.datatransfer.FlavorEvent 实例源码

项目:incubator-netbeans    文件:NbClipboardTimeoutTest.java   
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();
}
项目:openjdk-jdk10    文件:SunClipboard.java   
/**
 * 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);
                }
            }
        }
    }
}
项目:Prism-gsoc16    文件:GUIClipboard.java   
/** 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();
        }
    });
}
项目:incubator-netbeans    文件:NbClipboard.java   
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);
    }
}
项目: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);
    }
}
项目:openjdk9    文件:SunClipboard.java   
/**
 * 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);
                }
            }
        }
    }
}
项目:confluence.keygen    文件:TextActions.java   
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:    */     }
项目:opendocs    文件:PasteButton.java   
@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);
}
项目:Clipshare    文件:ClipboardListener.java   
@Override
public void flavorsChanged(FlavorEvent flavorEvent)
{
    System.out.println("Clipboard update detected (Flavor)");

    int[] currentRevision = ClipboardManager.getInstance().getCurrentRevision();
    regainOwnershipAndBroadcast(currentRevision);
}
项目:incubator-netbeans    文件:NbClipboard.java   
@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();
}
项目:incubator-netbeans    文件:ExplorerActionsImpl.java   
@Override
public void flavorsChanged(FlavorEvent ev) {
    schedule();
}
项目:widgetfx    文件:ClipboardHandler.java   
@Override
public void flavorsChanged(FlavorEvent e) {
  //System.out.println("----------> flavors changed");
  this.clipboardUpdated = true;
}
项目:netbeans-mmd-plugin    文件:MMDGraphEditor.java   
@Override
public void flavorsChanged(@Nonnull final FlavorEvent e) {
  processClipboardChange((Clipboard) e.getSource());
}
项目:ExtendedHodoku    文件:MainFrame.java   
@Override
public void flavorsChanged(FlavorEvent e) {
    adjustPasteMenuItem();
}
项目:JRLib    文件:PasteAction.java   
@Override
public void flavorsChanged(FlavorEvent e) {
    if(reactToClipboard)
        PasteAction.this.contextChanged();
}