Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
JBrowser Source Code Files
JBrowser Source Code Files are provided in the
source package file.
You can download JBrowser source package as described in the previous tutorial and go to the "src" sub-folder to view Source Code files.
You can also browse JBrowser Source Code files below:
✍: FYIcenter
⏎ ru/atomation/jbrowser/impl/DefaultBrowserClipboardManager.java
package ru.atomation.jbrowser.impl;
import java.awt.event.FocusEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mozilla.browser.MozillaExecutor;
import org.mozilla.interfaces.nsIClipboardCommands;
import ru.atomation.jbrowser.interfaces.Browser;
import ru.atomation.jbrowser.interfaces.BrowserAdapter;
import ru.atomation.jbrowser.interfaces.BrowserClipboardManager;
public class DefaultBrowserClipboardManager implements BrowserClipboardManager {
protected static Log logger = LogFactory.getLog(DefaultBrowserClipboardManager.class);
private final Browser browser;
private final nsIClipboardCommands nsIClipboardCommands;
private final List<Runnable> delayed;
public DefaultBrowserClipboardManager(Browser browser, nsIClipboardCommands nsIClipboardCommands) {
this.browser = browser;
this.nsIClipboardCommands = nsIClipboardCommands;
this.delayed = Collections.synchronizedList(new ArrayList<Runnable>());
this.browser.addBrowserListener(new BrowserAdapter() {
@Override
public void focusGained(FocusEvent e) {
synchronized (delayed) {
for (Runnable r: delayed) {
r.run();
}
delayed.clear();
}
}
});
}
/**
* Вернет false если не активен
*/
@Override
public boolean canCopyImageContents() {
try {
return nsIClipboardCommands.canCopyImageContents();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return false;
}
@Override
public boolean canCopyImageLocation() {
try {
return nsIClipboardCommands.canCopyImageLocation();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return false;
}
@Override
public boolean canCopyLinkLocation() {
try {
return nsIClipboardCommands.canCopyLinkLocation();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return false;
}
@Override
public boolean canCopySelection() {
try {
return nsIClipboardCommands.canCopySelection();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return false;
}
@Override
public boolean canCutSelection() {
try {
return nsIClipboardCommands.canCutSelection();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return false;
}
@Override
public boolean canPaste() {
try {
return nsIClipboardCommands.canPaste();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return false;
}
@Override
public void copyImageContents() {
invokeInMozillaThread(new Runnable() {
@Override
public void run() {
if (canCopyImageContents()) {
try {
nsIClipboardCommands.copyImageContents();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
});
}
@Override
public void copyImageLocation() {
invokeInMozillaThread(new Runnable() {
@Override
public void run() {
if (canCopyImageLocation()) {
try {
nsIClipboardCommands.copyImageLocation();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
});
}
@Override
public void copyLinkLocation() {
invokeInMozillaThread(new Runnable() {
@Override
public void run() {
if (canCopyLinkLocation()) {
try {
nsIClipboardCommands.copyLinkLocation();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
});
}
@Override
public void copySelection() {
invokeInMozillaThread(new Runnable() {
@Override
public void run() {
if (canCopySelection()) {
try{
nsIClipboardCommands.copySelection();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
});
}
@Override
public void cutSelection() {
invokeInMozillaThread(new Runnable() {
@Override
public void run() {
if (canCutSelection()) {
try {
nsIClipboardCommands.cutSelection();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
});
}
@Override
public void paste() {
invokeInMozillaThread(new Runnable() {
@Override
public void run() {
if (canPaste()) {
try {
nsIClipboardCommands.paste();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
});
}
protected void invokeInMozillaThread(final Runnable run) {
if (browser.isFocusOwner()) {
MozillaExecutor.mozAsyncExec(run);
} else {
synchronized (delayed) {
delayed.add(new Runnable() {
@Override
public void run() {
MozillaExecutor.mozAsyncExec(run);
}
});
}
browser.requestFocus();
}
}
}
⏎ ru/atomation/jbrowser/impl/DefaultBrowserClipboardManager.java
Or download all of them as a single archive file:
File name: jbrowser-1.9-fyi.zip File size: 625318 bytes Release date: 2022-11-10 Download
⇐ Download and Install JBrowser Source Package
2017-07-17, ≈27🔥, 1💬
Popular Posts:
JAX-WS is an API for building web services and clients. It is the next generation Web Services API r...
MP3SPI is a Java Service Provider Interface that adds MP3 (MPEG 1/2/2.5 Layer 1/2/3) audio format su...
What is the jaxp\TypeInfoWriter.java provided in the Apache Xerces package? I have Apache Xerces 2.1...
JDK 11 jdk.internal.JVM Stat.jmod is the JMOD file for JDK 11 Internal Jvmstat module. JDK 11 Intern...
How to download and install mysql-connector-j-8.0.31 .zip?Connector/J Java library is a JDBC Driver ...