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:
JDK 17 jdk.jfr.jmod is the JMOD file for JDK 17 JFR module. JDK 17 JFR module compiled class files a...
JDK 11 java.management.jmod is the JMOD file for JDK 11 Management module. JDK 11 Management module ...
How to download and install JDK (Java Development Kit) 1.3? If you want to write Java applications, ...
How to download and install iText7-Core-7.1.4.zip? iText7-Core-7.1.4.zip is the binary package of iT...
JDOM provides a solution for using XML from Java that is as simple as Java itself. There is no compe...