Java Examples for java.awt.Desktop.Action
The following java examples will help you to understand the usage of java.awt.Desktop.Action. These source code samples are taken from different open source projects.
Example 1
| Project: i2p.i2p-master File: I2PDesktop.java View source code |
public static void browse(String url) throws BrowseException {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Action.BROWSE)) {
try {
desktop.browse(new URI(url));
} catch (Exception e) {
throw new BrowseException();
}
} else {
throw new BrowseException();
}
} else {
throw new BrowseException();
}
}Example 2
| Project: olca-app-master File: Desktop.java View source code |
public static void browse(String uri) {
try {
if (java.awt.Desktop.isDesktopSupported()) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (desktop.isSupported(Action.BROWSE)) {
desktop.browse(new URI(uri));
}
}
} catch (Exception e) {
log.error("Browse URI failed", e);
}
}Example 3
| Project: dummydroid-master File: BrowseUtil.java View source code |
/**
* Open a url
*
* @param url
* url to open
* @return any exception that might be thrown
*/
public static Exception openUrl(String url) {
try {
if (java.awt.Desktop.isDesktopSupported()) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
java.net.URI uri = new java.net.URI(url);
desktop.browse(uri);
}
}
} catch (Exception e) {
e.printStackTrace();
return e;
}
return null;
}Example 4
| Project: Raccoon-master File: BrowseUtil.java View source code |
/**
* Open a url
*
* @param url
* url to open
* @return any exception that might be thrown
*/
public static Exception openUrl(String url) {
try {
if (java.awt.Desktop.isDesktopSupported()) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
java.net.URI uri = new java.net.URI(url);
desktop.browse(uri);
}
}
} catch (Exception e) {
e.printStackTrace();
return e;
}
return null;
}Example 5
| Project: DDS-Utils-master File: MoreWebbableView.java View source code |
public static void openURL(URI uri) {
if (!java.awt.Desktop.isDesktopSupported()) {
System.err.println("Desktop is not supported (fatal)");
System.exit(1);
}
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
System.err.println("Desktop doesn't support the browse action (fatal)");
System.exit(1);
}
try {
desktop.browse(uri);
} catch (Exception e) {
System.err.println(e.getMessage());
}
}Example 6
| Project: gvtools-master File: Help.java View source code |
public static void show() {
logger.info("show()");
try {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Action.BROWSE)) {
desktop.browse(new URI(WIKI_URL));
} else {
BrowserControl.displayURL(WIKI_URL);
}
} else {
BrowserControl.displayURL(WIKI_URL);
}
} catch (Exception e) {
logger.error("An exception has occurred while trying to show help", e);
BrowserControl.displayURL(WIKI_URL);
}
}Example 7
| Project: Put.io-master File: GetToken.java View source code |
public static void browse() {
if (!java.awt.Desktop.isDesktopSupported())
JOptionPane.showMessageDialog(null, "Desktop is not supported", "Error", JOptionPane.ERROR_MESSAGE);
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE))
JOptionPane.showMessageDialog(null, "Desktop doesn't support the browse action", "Error", JOptionPane.ERROR_MESSAGE);
try {
java.net.URI uri = new java.net.URI(url);
desktop.browse(uri);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
}Example 8
| Project: NearInfinity-master File: UrlBrowser.java View source code |
/** Opens the specified URL in the system's default browser. */
static boolean openUrl(String url) {
boolean retVal = false;
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
try {
desktop.browse(URI.create(url));
retVal = true;
} catch (IOException e) {
e.printStackTrace();
}
}
return retVal;
}Example 9
| Project: bladecoder-adventure-engine-master File: DesktopUtils.java View source code |
/**
* Opens the given website in the default browser.
*/
public static void browse(Component parent, String uri) {
boolean error = false;
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Action.BROWSE)) {
try {
Desktop.getDesktop().browse(new URI(uri));
} catch (URISyntaxException ex) {
throw new RuntimeException(ex);
} catch (IOException ex) {
error = true;
}
} else {
error = true;
}
if (error) {
String msg = "Impossible to open the default browser from the application";
JOptionPane.showMessageDialog(parent, msg);
}
}Example 10
| Project: mah-master File: DesktopUtils.java View source code |
public static void openBrowser(String url) {
if (java.awt.Desktop.isDesktopSupported()) {
try {
java.net.URI uri = java.net.URI.create(url);
java.awt.Desktop dp = java.awt.Desktop.getDesktop();
if (dp.isSupported(java.awt.Desktop.Action.BROWSE)) {
dp.browse(uri);
} else {
Runtime runtime = Runtime.getRuntime();
runtime.exec("xdg-open " + url);
}
} catch (Exception e1) {
throw new RuntimeException(e1);
}
}
}Example 11
| Project: OrganicBuilder-master File: AboutAction.java View source code |
/**
* Try to open the url with a browser. If not supported or in case of error,
* return false.
*/
private final boolean openUrlOnPage() {
if (Desktop.isDesktopSupported()) {
final Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
try {
desktop.browse(new URI(siteUrl));
return true;
} catch (final Exception e) {
}
}
}
return false;
}Example 12
| Project: vebugger-master File: DesktopActionTemplate.java View source code |
@Override
public void render(StringBuilder sb, Object obj) {
Action currentAction = (Action) obj;
sb.append("<style>");
sb.append("table.java-awt-Desktop-Action > tbody > tr > td {font-family: monospace; font-size: 0.7em; text-align: center;}");
sb.append("table.java-awt-Desktop-Action > tbody > tr > td.active {color: black;}");
sb.append("table.java-awt-Desktop-Action > tbody > tr > td.inactive {color: gray;}");
sb.append("</style>");
sb.append("<table class=\"java-awt-Desktop-Action\"><tbody><tr>");
for (Action someAction : Action.values()) {
sb.append("<td><img src=\"");
if (someAction == currentAction) {
sb.append(ENABLED.get(someAction));
} else {
sb.append(DISABLED.get(someAction));
}
sb.append("\" /></td>");
}
sb.append("</tr><tr>");
for (Action someAction : Action.values()) {
sb.append("<td class=\"");
if (someAction == currentAction) {
sb.append("active");
} else {
sb.append("inactive");
}
sb.append("\">").append(someAction.toString()).append("</td>");
}
sb.append("</tr></tbody></table>");
}Example 13
| Project: cropplanning-master File: GoogleCaptchaDialog.java View source code |
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source == btnLaunch) {
if (captchaUrl == null) {
System.err.println("No CAPTCHA URL defined");
} else if (java.awt.Desktop.isDesktopSupported()) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
try {
desktop.browse(captchaUrl.toURI());
} catch (Exception f) {
f.printStackTrace();
}
}
}
} else if (source == btnLogin) {
setVisible(false);
} else if (source == btnCancel) {
cancelled = true;
setVisible(false);
}
}Example 14
| Project: jadx-master File: Link.java View source code |
private void browse() {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Action.BROWSE)) {
try {
desktop.browse(new java.net.URI(url));
return;
} catch (IOException e) {
LOG.debug("Open url error", e);
} catch (URISyntaxException e) {
LOG.debug("Open url error", e);
}
}
}
try {
String os = System.getProperty("os.name").toLowerCase();
if (os.contains("win")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
return;
}
if (os.contains("mac")) {
Runtime.getRuntime().exec("open " + url);
return;
}
Map<String, String> env = System.getenv();
if (env.get("BROWSER") != null) {
Runtime.getRuntime().exec(env.get("BROWSER") + " " + url);
return;
}
} catch (Exception e) {
LOG.debug("Open url error", e);
}
showUrlDialog();
}Example 15
| Project: libgdx-master File: HeadlessNet.java View source code |
@Override
public boolean openURI(String URI) {
boolean result = false;
try {
if (!GraphicsEnvironment.isHeadless() && Desktop.isDesktopSupported()) {
if (Desktop.getDesktop().isSupported(Action.BROWSE)) {
Desktop.getDesktop().browse(java.net.URI.create(URI));
result = true;
}
} else {
Gdx.app.error("HeadlessNet", "Opening URIs on this environment is not supported. Ignoring.");
}
} catch (Throwable t) {
Gdx.app.error("HeadlessNet", "Failed to open URI. ", t);
}
return result;
}Example 16
| Project: Penn-TotalRecall-master File: VisitTutorialSiteAction.java View source code |
/**
* Attempts to guide the user's web browser to the program tutorial website.
*
* If the user cannot be brought to the program's tutorial site in the web browser, a dialog
* is launched containing the URL.
*/
public void actionPerformed(ActionEvent e) {
try {
//requires Java 6 API
if (java.awt.Desktop.isDesktopSupported()) {
if (java.awt.Desktop.getDesktop().isSupported(java.awt.Desktop.Action.BROWSE)) {
java.awt.Desktop.getDesktop().browse(new URI(Constants.tutorialSite));
}
}
return;
} catch (IOException e1) {
e1.printStackTrace();
} catch (URISyntaxException e1) {
e1.printStackTrace();
} catch (NoClassDefFoundError e1) {
System.err.println("Without Java 6 your browser cannot be launched");
e1.printStackTrace();
}
//in case Java 6 classes not available
GiveMessage.infoMessage(Constants.tutorialSite + "\n\n" + Constants.orgName + "\n" + Constants.orgAffiliationName);
}Example 17
| Project: AgentX-master File: Main.java View source code |
public static void popConsolePage() {
if (httpServer != null && httpServer.isRunning()) {
try {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
desktop.browse(java.net.URI.create("http://" + Configuration.INSTANCE.getConsoleDomain()));
} else {
log.warn("\tPop console page failed (not support)");
}
} catch (Exception e) {
log.warn("\tPop console page failed ({})", e.getMessage());
}
} else {
log.warn("\t{} has closed", Constants.WEB_SERVER_NAME);
}
}Example 18
| Project: AMIDST-master File: UpdateManager.java View source code |
public void run() {
try {
URL url = new URL(updateURL);
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse(url.openStream());
doc.getDocumentElement().normalize();
NodeList vlist = doc.getDocumentElement().getElementsByTagName("version");
NodeList version = vlist.item(0).getChildNodes();
int major = 0;
int minor = 0;
String updateURL = doc.getFirstChild().getAttributes().item(0).getNodeValue();
for (int i = 0; i < version.getLength(); i++) {
Node v = version.item(i);
if (v.getNodeType() == Node.ELEMENT_NODE) {
if (v.getNodeName().toLowerCase().equals("major")) {
major = Integer.parseInt(v.getAttributes().item(0).getNodeValue());
} else if (v.getNodeName().toLowerCase().equals("minor")) {
minor = Integer.parseInt(v.getAttributes().item(0).getNodeValue());
}
}
}
int n = JOptionPane.NO_OPTION;
if (major > Amidst.version_major) {
n = JOptionPane.showConfirmDialog(window, "A new version was found. Would you like to update?", "Update Found", JOptionPane.YES_NO_OPTION);
} else if ((major == Amidst.version_major) && (minor > Amidst.version_minor)) {
n = JOptionPane.showConfirmDialog(window, "A minor revision was found. Update?", "Update Found", JOptionPane.YES_NO_OPTION);
} else if (!silent)
JOptionPane.showMessageDialog(window, "There are no new updates.");
if (n == 0) {
if (!java.awt.Desktop.isDesktopSupported()) {
JOptionPane.showMessageDialog(window, "Error unable to open browser.");
}
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
JOptionPane.showMessageDialog(window, "Error unable to open browser page.");
}
java.net.URI uri = new java.net.URI(updateURL);
desktop.browse(uri);
}
} catch (MalformedURLException e1) {
if (!silent)
JOptionPane.showMessageDialog(window, "Error connecting to update server: Malformed URL.");
} catch (IOException e1) {
if (!silent)
JOptionPane.showMessageDialog(window, "Error reading update data.");
} catch (ParserConfigurationException e) {
if (!silent)
JOptionPane.showMessageDialog(window, "Error with XML parser configuration.");
} catch (SAXException e) {
if (!silent)
JOptionPane.showMessageDialog(window, "Error parsing update file.");
} catch (NumberFormatException e) {
if (!silent)
JOptionPane.showMessageDialog(window, "Error parsing version numbers.");
} catch (NullPointerException e) {
if (!silent)
JOptionPane.showMessageDialog(window, "Error \"NullPointerException\" in update.");
} catch (URISyntaxException e) {
if (!silent)
JOptionPane.showMessageDialog(window, "Error parsing update URL.");
}
}Example 19
| Project: desktop-crm-master File: DesktopUtil.java View source code |
public static void openBrowser(String url) {
try {
URI uri = new URI(url);
if (!open(uri) && Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Action.BROWSE))
try {
Desktop.getDesktop().browse(uri);
return;
} catch (Exception e) {
e.printStackTrace();
}
} catch (URISyntaxException e) {
e.printStackTrace();
}
}Example 20
| Project: Feuille-master File: ScriptPlugin.java View source code |
/** <p>Launch the selected link and open a browser.<br />
* Lance le lien sélectionné et ou un navigateur.</p> */
public static void openLink(String link) {
boolean hasResult = true;
if (java.awt.Desktop.isDesktopSupported()) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
try {
try {
desktop.browse(new java.net.URI(link));
} catch (java.io.IOException ex) {
hasResult = false;
}
} catch (java.net.URISyntaxException ex) {
hasResult = false;
}
} else {
hasResult = false;
}
} else {
hasResult = false;
}
if (hasResult == false) {
java.util.Properties sys = System.getProperties();
String os = sys.getProperty("os.name").toLowerCase();
try {
if (os.contains("windows") == true) {
Process proc = Runtime.getRuntime().exec("cmd /c start " + link);
} else {
Process proc = Runtime.getRuntime().exec("start " + link);
}
} catch (java.io.IOException e) {
}
}
}Example 21
| Project: Flickr4Java-master File: AuthInterfaceTest.java View source code |
@Test
@Ignore
public // Ignored as test is interactive so would fail a build
void testAuthFlow() throws FlickrException, IOException, URISyntaxException {
AuthInterface authInterface = flickr.getAuthInterface();
Token requestToken = authInterface.getRequestToken();
assertNotNull(requestToken);
assertNotNull(requestToken.getToken());
assertNotNull(requestToken.getSecret());
assertTrue(requestToken.getRawResponse().contains("oauth_callback_confirmed=true"));
String url = authInterface.getAuthorizationUrl(requestToken, Permission.READ);
assertNotNull(url);
assertEquals(String.format("http://www.flickr.com/services/oauth/authorize?oauth_token=%s&perms=%s", requestToken.getToken(), Permission.READ.toString()), url);
Desktop desktop = Desktop.getDesktop();
if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
System.out.println("Paste this URL into your browser");
System.out.println(url);
} else {
URI uri = new URI(url);
desktop.browse(uri);
}
Scanner in = new Scanner(System.in);
System.out.println("Enter the given authorization code provided by Flickr auth");
System.out.print(">>");
String code = in.nextLine();
assertNotNull(code);
Verifier verifier = new Verifier(code);
Token accessToken = authInterface.getAccessToken(requestToken, verifier);
assertNotNull(accessToken);
assertNotNull(accessToken.getToken());
assertNotNull(accessToken.getSecret());
Auth checkedAuth = authInterface.checkToken(accessToken);
assertNotNull(checkedAuth);
assertEquals(accessToken.getToken(), checkedAuth.getToken());
assertEquals(accessToken.getSecret(), checkedAuth.getTokenSecret());
assertEquals(Permission.READ, checkedAuth.getPermission());
assertNotNull(checkedAuth.getUser());
assertNotNull(checkedAuth.getUser().getUsername());
}Example 22
| Project: hfsexplorer-master File: Java6Util.java View source code |
private static boolean canOpenInternal() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, NoSuchFieldException {
Class<?> desktopClass = Class.forName("java.awt.Desktop");
Class<?> desktopActionClass = Class.forName("java.awt.Desktop$Action");
/* Desktop desktop = Desktop.getDesktop(); */
Method desktopGetDesktopMethod = desktopClass.getMethod("getDesktop");
Object desktopObject = desktopGetDesktopMethod.invoke(null);
/* Desktop.Action openAction = Desktop.Action.OPEN); */
Field desktopActionOpenField = desktopActionClass.getField("OPEN");
Object openActionObject = desktopActionOpenField.get(null);
/* return desktop.isSupported(openAction); */
Method desktopIsSupportedMethod = desktopClass.getMethod("isSupported", desktopActionClass);
Object returnObject = desktopIsSupportedMethod.invoke(desktopObject, openActionObject);
if (!(returnObject instanceof Boolean)) {
throw new RuntimeException("Unexpected type returned from " + "java.awt.Desktop.isSupported(java.awt.Desktop.Action): " + returnObject.getClass());
}
return ((Boolean) returnObject).booleanValue();
}Example 23
| Project: google-oauth-java-client-master File: AuthorizationCodeInstalledApp.java View source code |
/**
* Open a browser at the given URL using {@link Desktop} if available, or alternatively output the
* URL to {@link System#out} for command-line applications.
*
* @param url URL to browse
*/
public static void browse(String url) {
Preconditions.checkNotNull(url);
// Ask user to open in their browser using copy-paste
System.out.println("Please open the following address in your browser:");
System.out.println(" " + url);
// Attempt to open it in the browser
try {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Action.BROWSE)) {
System.out.println("Attempting to open that address in the default browser now...");
desktop.browse(URI.create(url));
}
}
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Unable to open browser", e);
} catch (InternalError e) {
LOGGER.log(Level.WARNING, "Unable to open browser", e);
}
}Example 24
| Project: idea-php-symfony2-plugin-master File: IdeHelper.java View source code |
public static void openUrl(String url) {
if (java.awt.Desktop.isDesktopSupported()) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
try {
java.net.URI uri = new java.net.URI(url);
desktop.browse(uri);
} catch (URISyntaxExceptionIOException | ignored) {
}
}
}
}Example 25
| Project: openjdk-master File: Desktop.java View source code |
/**
* Launches the default browser to display a {@code URI}.
* If the default browser is not able to handle the specified
* {@code URI}, the application registered for handling
* {@code URIs} of the specified type is invoked. The application
* is determined from the protocol and path of the {@code URI}, as
* defined by the {@code URI} class.
* <p>
* If the calling thread does not have the necessary permissions,
* and this is invoked from within an applet,
* {@code AppletContext.showDocument()} is used. Similarly, if the calling
* does not have the necessary permissions, and this is invoked from within
* a Java Web Started application, {@code BasicService.showDocument()}
* is used.
*
* @param uri the URI to be displayed in the user default browser
* @throws NullPointerException if {@code uri} is {@code null}
* @throws UnsupportedOperationException if the current platform
* does not support the {@link Desktop.Action#BROWSE} action
* @throws IOException if the user default browser is not found,
* or it fails to be launched, or the default handler application
* failed to be launched
* @throws SecurityException if a security manager exists and it
* denies the
* {@code AWTPermission("showWindowWithoutWarningBanner")}
* permission, or the calling thread is not allowed to create a
* subprocess; and not invoked from within an applet or Java Web Started
* application
* @throws IllegalArgumentException if the necessary permissions
* are not available and the URI can not be converted to a {@code URL}
* @see java.net.URI
* @see java.awt.AWTPermission
* @see java.applet.AppletContext
*/
public void browse(URI uri) throws IOException {
SecurityException securityException = null;
try {
checkAWTPermission();
checkExec();
} catch (SecurityException e) {
securityException = e;
}
checkActionSupport(Action.BROWSE);
if (uri == null) {
throw new NullPointerException();
}
if (securityException == null) {
peer.browse(uri);
return;
}
// Calling thread doesn't have necessary privileges.
// Delegate to DesktopBrowse so that it can work in
// applet/webstart.
URL url = null;
try {
url = uri.toURL();
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Unable to convert URI to URL", e);
}
sun.awt.DesktopBrowse db = sun.awt.DesktopBrowse.getInstance();
if (db == null) {
// Not in webstart/applet, throw the exception.
throw securityException;
}
db.browse(url);
}Example 26
| Project: SMEdit-master File: BegPanel.java View source code |
private void doGoto(String url) {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Action.BROWSE)) {
try {
desktop.browse(URI.create(url));
return;
} catch (IOException e) {
}
}
}
}Example 27
| Project: eclipse-mpc-master File: ShareSolutionLink.java View source code |
private boolean isMailSupported() {
// Desktop.getDesktop().isSupported(Action.MAIL)
try {
Class<?> desktopClazz = getDesktopClazz();
//$NON-NLS-1$
Method isDesktopSupportedMethod = desktopClazz.getMethod("isDesktopSupported");
boolean isDesktopSupported = (Boolean) isDesktopSupportedMethod.invoke(null);
//$NON-NLS-1$
Method getDesktopMethod = desktopClazz.getMethod("getDesktop");
Object desktop = getDesktopMethod.invoke(null);
Class<?>[] classes = desktopClazz.getClasses();
Class<?> actionEnum = null;
for (Class<?> innerClass : classes) {
if (//$NON-NLS-1$
innerClass.getName().equals("java.awt.Desktop$Action")) {
actionEnum = innerClass;
}
}
if (actionEnum == null) {
return false;
}
//$NON-NLS-1$
Method isSupportedMethod = desktop.getClass().getMethod("isSupported", actionEnum);
//$NON-NLS-1$
Field mailEnumOption = actionEnum.getDeclaredField("MAIL");
boolean isMailSupported = (Boolean) isSupportedMethod.invoke(desktop, mailEnumOption.get(null));
return isDesktopSupported && isMailSupported;
} catch (Exception e) {
}
return false;
}Example 28
| Project: epp.mpc-master File: ShareSolutionLink.java View source code |
private boolean isAwtMailSupported() {
if (Util.isGtk3()) {
return false;
}
try {
Class<?> desktopClazz = getDesktopClazz();
//$NON-NLS-1$
Method isDesktopSupportedMethod = desktopClazz.getMethod("isDesktopSupported");
boolean isDesktopSupported = (Boolean) isDesktopSupportedMethod.invoke(null);
if (!isDesktopSupported) {
return false;
}
//$NON-NLS-1$
Method getDesktopMethod = desktopClazz.getMethod("getDesktop");
Object desktop = getDesktopMethod.invoke(null);
Class<?>[] classes = desktopClazz.getClasses();
Class<?> actionEnum = null;
for (Class<?> innerClass : classes) {
if (//$NON-NLS-1$
innerClass.getName().equals("java.awt.Desktop$Action")) {
actionEnum = innerClass;
}
}
if (actionEnum == null) {
return false;
}
//$NON-NLS-1$
Method isSupportedMethod = desktop.getClass().getMethod("isSupported", actionEnum);
//$NON-NLS-1$
Field mailEnumOption = actionEnum.getDeclaredField("MAIL");
boolean isMailSupported = (Boolean) isSupportedMethod.invoke(desktop, mailEnumOption.get(null));
return isMailSupported;
} catch (Exception e) {
}
return false;
}Example 29
| Project: JamVM-PH-master File: ClasspathDesktopPeer.java View source code |
public boolean isSupported(Action action) {
String check = null;
switch(action) {
case BROWSE:
check = _BROWSE;
break;
case MAIL:
check = _MAIL;
break;
case EDIT:
check = _EDIT;
break;
case PRINT:
check = _PRINT;
break;
case OPEN:
default:
check = _OPEN;
break;
}
return this.supportCommand(check);
}Example 30
| Project: jdk7u-jdk-master File: Desktop.java View source code |
/**
* Launches the default browser to display a {@code URI}.
* If the default browser is not able to handle the specified
* {@code URI}, the application registered for handling
* {@code URIs} of the specified type is invoked. The application
* is determined from the protocol and path of the {@code URI}, as
* defined by the {@code URI} class.
* <p>
* If the calling thread does not have the necessary permissions,
* and this is invoked from within an applet,
* {@code AppletContext.showDocument()} is used. Similarly, if the calling
* does not have the necessary permissions, and this is invoked from within
* a Java Web Started application, {@code BasicService.showDocument()}
* is used.
*
* @param uri the URI to be displayed in the user default browser
* @throws NullPointerException if {@code uri} is {@code null}
* @throws UnsupportedOperationException if the current platform
* does not support the {@link Desktop.Action#BROWSE} action
* @throws IOException if the user default browser is not found,
* or it fails to be launched, or the default handler application
* failed to be launched
* @throws SecurityException if a security manager exists and it
* denies the
* <code>AWTPermission("showWindowWithoutWarningBanner")</code>
* permission, or the calling thread is not allowed to create a
* subprocess; and not invoked from within an applet or Java Web Started
* application
* @throws IllegalArgumentException if the necessary permissions
* are not available and the URI can not be converted to a {@code URL}
* @see java.net.URI
* @see java.awt.AWTPermission
* @see java.applet.AppletContext
*/
public void browse(URI uri) throws IOException {
SecurityException securityException = null;
try {
checkAWTPermission();
checkExec();
} catch (SecurityException e) {
securityException = e;
}
checkActionSupport(Action.BROWSE);
if (uri == null) {
throw new NullPointerException();
}
if (securityException == null) {
peer.browse(uri);
return;
}
// Calling thread doesn't have necessary priviledges.
// Delegate to DesktopBrowse so that it can work in
// applet/webstart.
URL url = null;
try {
url = uri.toURL();
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Unable to convert URI to URL", e);
}
sun.awt.DesktopBrowse db = sun.awt.DesktopBrowse.getInstance();
if (db == null) {
// Not in webstart/applet, throw the exception.
throw securityException;
}
db.browse(url);
}Example 31
| Project: Midgard-master File: OAuth2Native.java View source code |
/** Open a browser at the given URL. */
private static void browse(String url) {
// first try the Java Desktop
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Action.BROWSE)) {
try {
desktop.browse(URI.create(url));
return;
} catch (IOException e) {
}
}
}
// Next try rundll32 (only works on Windows)
try {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
return;
} catch (IOException e) {
}
// Next try the requested browser (e.g. "google-chrome")
if (BROWSER != null) {
try {
Runtime.getRuntime().exec(new String[] { BROWSER, url });
return;
} catch (IOException e) {
}
}
// Finally just ask user to open in their browser using copy-paste
System.out.println("Please open the following URL in your browser:");
System.out.println(" " + url);
}Example 32
| Project: mobac-ext-master File: Logging.java View source code |
public static void logSystemInfo() {
Logger log = Logger.getLogger("SysInfo");
if (log.isInfoEnabled()) {
String n = System.getProperty("line.separator");
log.info("Version: " + ProgramInfo.getCompleteTitle());
log.info("Platform: " + GUIExceptionHandler.prop("os.name") + " (" + GUIExceptionHandler.prop("os.version") + ")");
log.info("Java VM: " + GUIExceptionHandler.prop("java.vm.name") + " (" + GUIExceptionHandler.prop("java.runtime.version") + ")");
log.info("Directories:" + n + "currentDir: \t\t" + DirectoryManager/**/
.currentDir + n + "programDir: \t\t" + DirectoryManager/**/
.programDir + n + "tempDir: \t\t" + DirectoryManager/**/
.tempDir + n + "userHomeDir: \t\t" + DirectoryManager/**/
.userHomeDir + n + "userSettingsDir: \t" + DirectoryManager.userSettingsDir + n + "atlasProfilesDir: \t" + DirectoryManager.atlasProfilesDir + n + "userAppDataDir: \t" + DirectoryManager.userAppDataDir);
log.info("System console available: " + (System.console() != null));
log.info("Startup arguments (count=" + StartMOBAC.ARGS.length + "):");
for (int i = 0; i < StartMOBAC.ARGS.length; i++) log.info("\t" + i + ": " + StartMOBAC.ARGS[i]);
}
if (log.isDebugEnabled()) {
log.debug("Detected operating system: " + OSUtilities.detectOs() + " (" + System.getProperty("os.name") + ")");
boolean desktopSupport = Desktop.isDesktopSupported();
log.debug("Desktop support: " + desktopSupport);
if (desktopSupport) {
Desktop d = Desktop.getDesktop();
for (Action a : Action.values()) {
log.debug("Desktop action " + a + " supported: " + d.isSupported(a));
}
}
}
if (log.isTraceEnabled()) {
Properties props = System.getProperties();
StringWriter sw = new StringWriter(2 << 13);
sw.write("System properties:\n");
TreeMap<Object, Object> sortedProps = new TreeMap<Object, Object>(props);
for (Entry<Object, Object> entry : sortedProps.entrySet()) {
sw.write(entry.getKey() + " = " + entry.getValue() + "\n");
}
log.trace(sw.toString());
}
}Example 33
| Project: MOBAC-master File: Logging.java View source code |
public static void logSystemInfo() {
Logger log = Logger.getLogger("SysInfo");
if (log.isInfoEnabled()) {
String n = System.getProperty("line.separator");
log.info("Version: " + ProgramInfo.getCompleteTitle());
log.info("Platform: " + GUIExceptionHandler.prop("os.name") + " (" + GUIExceptionHandler.prop("os.version") + ")");
log.info("Java VM: " + GUIExceptionHandler.prop("java.vm.name") + " (" + GUIExceptionHandler.prop("java.runtime.version") + ")");
log.info("Directories:" + n + "currentDir: \t\t" + DirectoryManager/**/
.currentDir + n + "programDir: \t\t" + DirectoryManager/**/
.programDir + n + "tempDir: \t\t" + DirectoryManager/**/
.tempDir + n + "userHomeDir: \t\t" + DirectoryManager/**/
.userHomeDir + n + "userSettingsDir: \t" + DirectoryManager.userSettingsDir + n + "atlasProfilesDir: \t" + DirectoryManager.atlasProfilesDir + n + "userAppDataDir: \t" + DirectoryManager.userAppDataDir);
log.info("System console available: " + (System.console() != null));
log.info("Startup arguments (count=" + StartMOBAC.ARGS.length + "):");
for (int i = 0; i < StartMOBAC.ARGS.length; i++) log.info("\t" + i + ": " + StartMOBAC.ARGS[i]);
}
if (log.isDebugEnabled()) {
log.debug("Detected operating system: " + OSUtilities.detectOs() + " (" + System.getProperty("os.name") + ")");
boolean desktopSupport = Desktop.isDesktopSupported();
log.debug("Desktop support: " + desktopSupport);
if (desktopSupport) {
Desktop d = Desktop.getDesktop();
for (Action a : Action.values()) {
log.debug("Desktop action " + a + " supported: " + d.isSupported(a));
}
}
}
if (log.isTraceEnabled()) {
Properties props = System.getProperties();
StringWriter sw = new StringWriter(2 << 13);
sw.write("System properties:\n");
TreeMap<Object, Object> sortedProps = new TreeMap<Object, Object>(props);
for (Entry<Object, Object> entry : sortedProps.entrySet()) {
sw.write(entry.getKey() + " = " + entry.getValue() + "\n");
}
log.trace(sw.toString());
}
}Example 34
| Project: Qwiksnap-master File: ScreenShotImage.java View source code |
@Override
public void mouseClicked(MouseEvent e) {
if (getLink() == null)
return;
switch(e.getButton()) {
case MouseEvent.BUTTON1:
if (!java.awt.Desktop.isDesktopSupported()) {
JOptionPane.showMessageDialog(null, "You computer does not support AWT Desktop :(", "Desktop is not supported!", 2);
}
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
JOptionPane.showMessageDialog(null, "You computer does not support AWT Desktop Browsing :(", "Desktop Browse is not supported!", 2);
}
try {
desktop.browse(new URI(getLink().getLink()));
} catch (Exception ed) {
}
//JOptionPane.showMessageDialog(null, "", getLink().getLink(), JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getFileLocation()));
break;
case MouseEvent.BUTTON3:
selected = !selected;
changeUpload(selected);
break;
}
}Example 35
| Project: socialauth-master File: GenerateToken.java View source code |
private void getAccessToken() throws Exception {
SocialAuthConfig config = SocialAuthConfig.getDefault();
config.load();
SocialAuthManager manager = new SocialAuthManager();
manager.setSocialAuthConfig(config);
URL aURL = new URL(successURL);
host = aURL.getHost();
port = aURL.getPort();
port = port == -1 ? 80 : port;
callbackPath = aURL.getPath();
if (tokenFilePath == null) {
tokenFilePath = System.getProperty("user.home");
}
String url = manager.getAuthenticationUrl(providerId, successURL);
startServer();
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Action.BROWSE)) {
try {
desktop.browse(URI.create(url));
// return;
} catch (IOException e) {
}
}
}
lock.lock();
try {
while (paramsMap == null && error == null) {
gotAuthorizationResponse.awaitUninterruptibly();
}
if (error != null) {
throw new IOException("User authorization failed (" + error + ")");
}
} finally {
lock.unlock();
}
stop();
AccessGrant accessGrant = manager.createAccessGrant(providerId, paramsMap, successURL);
Exporter.exportAccessGrant(accessGrant, tokenFilePath);
LOG.info("Access Grant Object saved in a file :: " + tokenFilePath + File.separatorChar + accessGrant.getProviderId() + "_accessGrant_file.txt");
}Example 36
| Project: FDEB-master File: BannerComponent.java View source code |
@Override
public void actionPerformed(ActionEvent e) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
try {
java.net.URI uri = new java.net.URI("http://gephi.org");
desktop.browse(uri);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}Example 37
| Project: ganttproject-master File: BrowserControl.java View source code |
private static boolean displayUrlWithDesktopApi(String url) {
if (!java.awt.Desktop.isDesktopSupported()) {
return false;
}
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
return false;
}
try {
desktop.browse(new URI(url));
} catch (IOException e) {
e.printStackTrace();
return false;
} catch (URISyntaxException e) {
e.printStackTrace();
return false;
}
return true;
}Example 38
| Project: gephi-gsoc13-legendmodule-master File: BannerComponent.java View source code |
@Override
public void actionPerformed(ActionEvent e) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
try {
java.net.URI uri = new java.net.URI("http://gephi.org");
desktop.browse(uri);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}Example 39
| Project: gephi-master File: BannerComponent.java View source code |
@Override
public void actionPerformed(ActionEvent e) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
try {
java.net.URI uri = new java.net.URI("http://gephi.org");
desktop.browse(uri);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}Example 40
| Project: nifty-gui-master File: MainPage.java View source code |
public void openLink(@Nonnull final String url) {
if (!java.awt.Desktop.isDesktopSupported()) {
System.err.println("Desktop is not supported (Can't open link)");
return;
}
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
System.err.println("Desktop (BROWSE) is not supported (Can't open link)");
return;
}
try {
java.net.URI uri = new java.net.URI(url);
desktop.browse(uri);
} catch (Exception e) {
e.printStackTrace();
}
}Example 41
| Project: opencmis-master File: ConsoleHelper.java View source code |
private static void addConsoleMenu(JMenu menu, String title, final URI url) {
if (!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Action.BROWSE)) {
return;
}
JMenuItem menuItem = new JMenuItem(title);
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Desktop.getDesktop().browse(url);
} catch (IOException ex) {
ClientHelper.showError(null, ex);
}
}
});
menu.add(menuItem);
}Example 42
| Project: swingx-master File: HighlighterExtDemo.java View source code |
@Action
public void fadeIn() {
if (fadeInTimeline == null) {
fadeInTimeline = new Timeline(this);
fadeInTimeline.addPropertyToInterpolate("background", PaintUtils.setAlpha(base, 0), PaintUtils.setAlpha(base, 125));
fadeInTimeline.setDuration(2000);
fadeInTimeline.setEase(new Spline(0.7f));
}
fadeInTimeline.replay();
}Example 43
| Project: Viz-master File: BannerComponent.java View source code |
@Override
public void actionPerformed(ActionEvent e) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
try {
java.net.URI uri = new java.net.URI("http://gephi.org");
desktop.browse(uri);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}Example 44
| Project: gephi-neo4j-plugin-master File: BannerTopComponent.java View source code |
@Override
public void actionPerformed(ActionEvent e) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
try {
java.net.URI uri = new java.net.URI("http://gephi.org");
desktop.browse(uri);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}Example 45
| Project: SketchChair-master File: SketchChairCloudhook.java View source code |
/*
* Share The chaire online upload and setup everything needed for the design
*/
public void ShareChairOnline(GUIEvent e) {
LOGGER.info("About to upload:");
//Make sure a design is selected
if (GLOBAL.sketchChairs.getCurChair() == null)
return;
String sharedChairID = "";
String[][] sessionIDargs = new String[1][2];
if (GLOBAL.sessionID != null) {
sessionIDargs[0][0] = "sessionID";
sessionIDargs[0][1] = GLOBAL.sessionID;
} else {
sessionIDargs = new String[0][0];
}
//Upload the design file
if (GLOBAL.cloudHook.postAction("isLoggedIn_CH", sessionIDargs).startsWith("FALSE")) {
loginBox();
return;
} else {
LOGGER.info("logged in with session");
}
//Here we might also want to check if we have rights to change this chair?
if (GLOBAL.sketchChairs.getCurChair().cloudID != null)
sharedChairID = GLOBAL.sketchChairs.getCurChair().cloudID;
else
sharedChairID = null;
LOGGER.info("ABOUT TO SETUP");
//setup the chair online, If the design already exists but we do not have right to update it then create as a new design
sharedChairID = setupOnline(sharedChairID);
LOGGER.info("Current ID: " + sharedChairID);
//Could not setup the chair
if (sharedChairID.startsWith("ERROR")) {
return;
}
//set the new cloudID
GLOBAL.sketchChairs.getCurChair().cloudID = sharedChairID;
LOGGER.info("Uploading Model:");
//Upload the design file
if (uploadModel(sharedChairID).startsWith("ERROR")) {
LOGGER.info("ERROR Uploading Model:");
return;
}
LOGGER.info("Uploading Screenshot:");
//upload a screenshot of the chair, this takes a bit of bandwidth
if (uploadScreenshot(sharedChairID).startsWith("ERROR")) {
LOGGER.info("ERROR Uploading Screenshot:");
return;
}
LOGGER.info("Uploading Pattern: 1:12");
//upload the pattern, do we need to do this all the time? takes a long time to compute
if (uploadPattern(sharedChairID, 0.08333333333333f, 1.0f, 197, 210, false, false, false, true).startsWith("ERROR")) {
LOGGER.info("ERROR Uploading Pattern:");
return;
}
LOGGER.info("Uploading Pattern: 1:9 0.15 paper");
//upload the pattern, do we need to do this all the time? takes a long time to compute
if (uploadPattern(sharedChairID, 0.11111111111111f, 0.15f, 197, 210, false, true, false, true).startsWith("ERROR")) {
LOGGER.info("ERROR Uploading Pattern:");
return;
}
LOGGER.info("Uploading Pattern: 1:1 12mm ply");
//upload the pattern, do we need to do this all the time? takes a long time to compute
if (uploadPattern(sharedChairID, 1f, 12.0f, 1200, 2100, false, false, true, true).startsWith("ERROR")) {
LOGGER.info("ERROR Uploading Pattern:");
return;
}
LOGGER.info("FINISHED: shared online :) ");
//System.out.println(result);
if (!SETTINGS.WEB_MODE) {
GLOBAL.applet.link("http://www.SketchChair.cc/design/" + sharedChairID + "/edit");
}
if (SETTINGS.WEB_MODE) {
// not compatible in JRE 1.5
/*
if( java.awt.Desktop.isDesktopSupported() )
{
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if( desktop.isSupported( java.awt.Desktop.Action.BROWSE ) )
{
try
{
java.net.URI uri = new java.net.URI( "http://www.SketchChair.com/viewChair.php?id=" +sharedChairID );
desktop.browse( uri );
}
catch( Exception ex )
{
java.io.StringWriter sw = new java.io.StringWriter();
java.io.PrintWriter pw = new java.io.PrintWriter( sw );
ex.printStackTrace( pw );
// log.error( "Error " + sw.toString() );
}
}
}
*/
}
}Example 46
| Project: yawls-master File: MainGUI.java View source code |
@Override
public void onActivate(MenuItem arg0) {
// Open launchpad.net project questions web page
if (java.awt.Desktop.isDesktopSupported()) {
final java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
java.net.URI uri;
try {
// Set URL for launchpad.net FAQ
uri = new java.net.URI(Database.QUESTIONS);
desktop.browse(uri);
} catch (final URISyntaxException e) {
Debug.LOG.log(Level.SEVERE, "Wrong URL syntax: " + Database.QUESTIONS, e);
} catch (final IOException e) {
Debug.LOG.log(Level.WARNING, "Could not start default browser.", e);
}
}
}
}Example 47
| Project: Offene-Pflege.de-master File: SYSFilesTools.java View source code |
/**
* Diese Methode ermittelt zu einer gebenen Datei und einer gewünschten Aktion das passende Anzeigeprogramm.
* Falls die Desktop API nicht passendes hat, werdne die lokal definierten Anzeigeprogramme verwendet.
* <p>
* Bei Linux müssen dafür unbedingt die Gnome Libraries installiert sein.
* apt-get install libgnome2-0
*
* @param file
* @param action
*/
public static void handleFile(File file, java.awt.Desktop.Action action) {
if (file == null) {
return;
}
Desktop desktop = null;
if (getLocalDefinedApp(file) != null) {
try {
Runtime.getRuntime().exec(getLocalDefinedApp(file));
} catch (IOException ex) {
OPDE.getLogger().error(ex);
}
} else {
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
if (action == Desktop.Action.OPEN && desktop.isSupported(Desktop.Action.OPEN)) {
try {
desktop.open(file);
} catch (IOException ex) {
OPDE.getDisplayManager().addSubMessage(new DisplayMessage(SYSTools.xx("misc.msg.noviewer"), DisplayMessage.WARNING));
}
} else if (action == Desktop.Action.PRINT && desktop.isSupported(Desktop.Action.PRINT)) {
try {
desktop.print(file);
} catch (IOException ex) {
OPDE.getDisplayManager().addSubMessage(new DisplayMessage(SYSTools.xx("misc.msg.noprintprog"), DisplayMessage.WARNING));
}
} else {
OPDE.getDisplayManager().addSubMessage(new DisplayMessage(SYSTools.xx("misc.msg.nofilehandler"), DisplayMessage.WARNING));
}
} else {
OPDE.getDisplayManager().addSubMessage(new DisplayMessage(SYSTools.xx("misc.msg.nojavadesktop"), DisplayMessage.WARNING));
}
}
}Example 48
| Project: ae-awt-master File: Desktop.java View source code |
/**
* Launches the default browser to display a {@code URI}.
* If the default browser is not able to handle the specified
* {@code URI}, the application registered for handling
* {@code URIs} of the specified type is invoked. The application
* is determined from the protocol and path of the {@code URI}, as
* defined by the {@code URI} class.
* <p>
* If the calling thread does not have the necessary permissions,
* and this is invoked from within an applet,
* {@code AppletContext.showDocument()} is used. Similarly, if the calling
* does not have the necessary permissions, and this is invoked from within
* a Java Web Started application, {@code BasicService.showDocument()}
* is used.
*
* @param uri the URI to be displayed in the user default browser
* @throws NullPointerException if {@code uri} is {@code null}
* @throws UnsupportedOperationException if the current platform
* does not support the {@link Desktop.Action#BROWSE} action
* @throws IOException if the user default browser is not found,
* or it fails to be launched, or the default handler application
* failed to be launched
* @throws SecurityException if a security manager exists and it
* denies the
* <code>AWTPermission("showWindowWithoutWarningBanner")</code>
* permission, or the calling thread is not allowed to create a
* subprocess; and not invoked from within an applet or Java Web Started
* application
* @throws IllegalArgumentException if the necessary permissions
* are not available and the URI can not be converted to a {@code URL}
* @see java.net.URI
* @see ae.java.awt.AWTPermission
* @see java.applet.AppletContext
*/
public void browse(URI uri) throws IOException {
SecurityException securityException = null;
try {
checkAWTPermission();
checkExec();
} catch (SecurityException e) {
securityException = e;
}
checkActionSupport(Action.BROWSE);
if (uri == null) {
throw new NullPointerException();
}
if (securityException == null) {
peer.browse(uri);
return;
}
// Calling thread doesn't have necessary priviledges.
// Delegate to DesktopBrowse so that it can work in
// applet/webstart.
URL url = null;
try {
url = uri.toURL();
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Unable to convert URI to URL", e);
}
ae.sun.awt.DesktopBrowse db = ae.sun.awt.DesktopBrowse.getInstance();
if (db == null) {
// Not in webstart/applet, throw the exception.
throw securityException;
}
db.browse(url);
}Example 49
| Project: Baseform-Epanet-Java-Library-master File: EpanetUI.java View source code |
/**
* Open the aware-p webpage in the browser.
*
* @param url
*/
private void browse(String url) {
if (!java.awt.Desktop.isDesktopSupported()) {
System.err.println("Desktop is not supported");
return;
}
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
System.err.println("Desktop doesn't support the browse action");
System.exit(1);
}
try {
java.net.URI uri = new java.net.URI(url);
desktop.browse(uri);
} catch (Exception e) {
System.err.println(e.getMessage());
}
}Example 50
| Project: classlib6-master File: Desktop.java View source code |
/**
* Launches the default browser to display a {@code URI}.
* If the default browser is not able to handle the specified
* {@code URI}, the application registered for handling
* {@code URIs} of the specified type is invoked. The application
* is determined from the protocol and path of the {@code URI}, as
* defined by the {@code URI} class.
* <p>
* If the calling thread does not have the necessary permissions,
* and this is invoked from within an applet,
* {@code AppletContext.showDocument()} is used. Similarly, if the calling
* does not have the necessary permissions, and this is invoked from within
* a Java Web Started application, {@code BasicService.showDocument()}
* is used.
*
* @param uri the URI to be displayed in the user default browser
* @throws NullPointerException if {@code uri} is {@code null}
* @throws UnsupportedOperationException if the current platform
* does not support the {@link Desktop.Action#BROWSE} action
* @throws IOException if the user default browser is not found,
* or it fails to be launched, or the default handler application
* failed to be launched
* @throws SecurityException if a security manager exists and it
* denies the
* <code>AWTPermission("showWindowWithoutWarningBanner")</code>
* permission, or the calling thread is not allowed to create a
* subprocess; and not invoked from within an applet or Java Web Started
* application
* @throws IllegalArgumentException if the necessary permissions
* are not available and the URI can not be converted to a {@code URL}
* @see java.net.URI
* @see java.awt.AWTPermission
* @see java.applet.AppletContext
*/
public void browse(URI uri) throws IOException {
SecurityException securityException = null;
try {
checkAWTPermission();
checkExec();
} catch (SecurityException e) {
securityException = e;
}
checkActionSupport(Action.BROWSE);
if (uri == null) {
throw new NullPointerException();
}
if (securityException == null) {
peer.browse(uri);
return;
}
// Calling thread doesn't have necessary priviledges.
// Delegate to DesktopBrowse so that it can work in
// applet/webstart.
URL url = null;
try {
url = uri.toURL();
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Unable to convert URI to URL", e);
}
sun.awt.DesktopBrowse db = sun.awt.DesktopBrowse.getInstance();
if (db == null) {
// Not in webstart/applet, throw the exception.
throw securityException;
}
db.browse(url);
}Example 51
| Project: ikvm-openjdk-master File: Desktop.java View source code |
/**
* Launches the default browser to display a {@code URI}.
* If the default browser is not able to handle the specified
* {@code URI}, the application registered for handling
* {@code URIs} of the specified type is invoked. The application
* is determined from the protocol and path of the {@code URI}, as
* defined by the {@code URI} class.
* <p>
* If the calling thread does not have the necessary permissions,
* and this is invoked from within an applet,
* {@code AppletContext.showDocument()} is used. Similarly, if the calling
* does not have the necessary permissions, and this is invoked from within
* a Java Web Started application, {@code BasicService.showDocument()}
* is used.
*
* @param uri the URI to be displayed in the user default browser
* @throws NullPointerException if {@code uri} is {@code null}
* @throws UnsupportedOperationException if the current platform
* does not support the {@link Desktop.Action#BROWSE} action
* @throws IOException if the user default browser is not found,
* or it fails to be launched, or the default handler application
* failed to be launched
* @throws SecurityException if a security manager exists and it
* denies the
* <code>AWTPermission("showWindowWithoutWarningBanner")</code>
* permission, or the calling thread is not allowed to create a
* subprocess; and not invoked from within an applet or Java Web Started
* application
* @throws IllegalArgumentException if the necessary permissions
* are not available and the URI can not be converted to a {@code URL}
* @see java.net.URI
* @see java.awt.AWTPermission
* @see java.applet.AppletContext
*/
public void browse(URI uri) throws IOException {
SecurityException securityException = null;
try {
checkAWTPermission();
checkExec();
} catch (SecurityException e) {
securityException = e;
}
checkActionSupport(Action.BROWSE);
if (uri == null) {
throw new NullPointerException();
}
if (securityException == null) {
peer.browse(uri);
return;
}
// Calling thread doesn't have necessary priviledges.
// Delegate to DesktopBrowse so that it can work in
// applet/webstart.
URL url = null;
try {
url = uri.toURL();
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Unable to convert URI to URL", e);
}
sun.awt.DesktopBrowse db = sun.awt.DesktopBrowse.getInstance();
if (db == null) {
// Not in webstart/applet, throw the exception.
throw securityException;
}
db.browse(url);
}Example 52
| Project: JDK-master File: Desktop.java View source code |
/**
* Launches the default browser to display a {@code URI}.
* If the default browser is not able to handle the specified
* {@code URI}, the application registered for handling
* {@code URIs} of the specified type is invoked. The application
* is determined from the protocol and path of the {@code URI}, as
* defined by the {@code URI} class.
* <p>
* If the calling thread does not have the necessary permissions,
* and this is invoked from within an applet,
* {@code AppletContext.showDocument()} is used. Similarly, if the calling
* does not have the necessary permissions, and this is invoked from within
* a Java Web Started application, {@code BasicService.showDocument()}
* is used.
*
* @param uri the URI to be displayed in the user default browser
* @throws NullPointerException if {@code uri} is {@code null}
* @throws UnsupportedOperationException if the current platform
* does not support the {@link Desktop.Action#BROWSE} action
* @throws IOException if the user default browser is not found,
* or it fails to be launched, or the default handler application
* failed to be launched
* @throws SecurityException if a security manager exists and it
* denies the
* <code>AWTPermission("showWindowWithoutWarningBanner")</code>
* permission, or the calling thread is not allowed to create a
* subprocess; and not invoked from within an applet or Java Web Started
* application
* @throws IllegalArgumentException if the necessary permissions
* are not available and the URI can not be converted to a {@code URL}
* @see java.net.URI
* @see java.awt.AWTPermission
* @see java.applet.AppletContext
*/
public void browse(URI uri) throws IOException {
SecurityException securityException = null;
try {
checkAWTPermission();
checkExec();
} catch (SecurityException e) {
securityException = e;
}
checkActionSupport(Action.BROWSE);
if (uri == null) {
throw new NullPointerException();
}
if (securityException == null) {
peer.browse(uri);
return;
}
// Calling thread doesn't have necessary priviledges.
// Delegate to DesktopBrowse so that it can work in
// applet/webstart.
URL url = null;
try {
url = uri.toURL();
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Unable to convert URI to URL", e);
}
sun.awt.DesktopBrowse db = sun.awt.DesktopBrowse.getInstance();
if (db == null) {
// Not in webstart/applet, throw the exception.
throw securityException;
}
db.browse(url);
}Example 53
| Project: lire-master File: FileUtils.java View source code |
/**
* Opens a browser windows th<t shows the given URI.
*
* @param uri the path to the file to show in the browser window.
*/
public static void browseUri(String uri) {
if (!java.awt.Desktop.isDesktopSupported()) {
System.err.println("Desktop is not supported (fatal)");
System.exit(1);
}
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
System.err.println("Desktop doesn't support the browse action (fatal)");
System.exit(1);
}
try {
java.net.URI url = new java.net.URI(uri);
desktop.browse(url);
} catch (Exception e) {
System.err.println(e.getMessage());
}
}Example 54
| Project: ManagedRuntimeInitiative-master File: Desktop.java View source code |
/**
* Launches the default browser to display a {@code URI}.
* If the default browser is not able to handle the specified
* {@code URI}, the application registered for handling
* {@code URIs} of the specified type is invoked. The application
* is determined from the protocol and path of the {@code URI}, as
* defined by the {@code URI} class.
* <p>
* If the calling thread does not have the necessary permissions,
* and this is invoked from within an applet,
* {@code AppletContext.showDocument()} is used. Similarly, if the calling
* does not have the necessary permissions, and this is invoked from within
* a Java Web Started application, {@code BasicService.showDocument()}
* is used.
*
* @param uri the URI to be displayed in the user default browser
* @throws NullPointerException if {@code uri} is {@code null}
* @throws UnsupportedOperationException if the current platform
* does not support the {@link Desktop.Action#BROWSE} action
* @throws IOException if the user default browser is not found,
* or it fails to be launched, or the default handler application
* failed to be launched
* @throws SecurityException if a security manager exists and it
* denies the
* <code>AWTPermission("showWindowWithoutWarningBanner")</code>
* permission, or the calling thread is not allowed to create a
* subprocess; and not invoked from within an applet or Java Web Started
* application
* @throws IllegalArgumentException if the necessary permissions
* are not available and the URI can not be converted to a {@code URL}
* @see java.net.URI
* @see java.awt.AWTPermission
* @see java.applet.AppletContext
*/
public void browse(URI uri) throws IOException {
SecurityException securityException = null;
try {
checkAWTPermission();
checkExec();
} catch (SecurityException e) {
securityException = e;
}
checkActionSupport(Action.BROWSE);
if (uri == null) {
throw new NullPointerException();
}
if (securityException == null) {
peer.browse(uri);
return;
}
// Calling thread doesn't have necessary priviledges.
// Delegate to DesktopBrowse so that it can work in
// applet/webstart.
URL url = null;
try {
url = uri.toURL();
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Unable to convert URI to URL", e);
}
sun.awt.DesktopBrowse db = sun.awt.DesktopBrowse.getInstance();
if (db == null) {
// Not in webstart/applet, throw the exception.
throw securityException;
}
db.browse(url);
}Example 55
| Project: openjdk8-jdk-master File: Desktop.java View source code |
/**
* Launches the default browser to display a {@code URI}.
* If the default browser is not able to handle the specified
* {@code URI}, the application registered for handling
* {@code URIs} of the specified type is invoked. The application
* is determined from the protocol and path of the {@code URI}, as
* defined by the {@code URI} class.
* <p>
* If the calling thread does not have the necessary permissions,
* and this is invoked from within an applet,
* {@code AppletContext.showDocument()} is used. Similarly, if the calling
* does not have the necessary permissions, and this is invoked from within
* a Java Web Started application, {@code BasicService.showDocument()}
* is used.
*
* @param uri the URI to be displayed in the user default browser
* @throws NullPointerException if {@code uri} is {@code null}
* @throws UnsupportedOperationException if the current platform
* does not support the {@link Desktop.Action#BROWSE} action
* @throws IOException if the user default browser is not found,
* or it fails to be launched, or the default handler application
* failed to be launched
* @throws SecurityException if a security manager exists and it
* denies the
* <code>AWTPermission("showWindowWithoutWarningBanner")</code>
* permission, or the calling thread is not allowed to create a
* subprocess; and not invoked from within an applet or Java Web Started
* application
* @throws IllegalArgumentException if the necessary permissions
* are not available and the URI can not be converted to a {@code URL}
* @see java.net.URI
* @see java.awt.AWTPermission
* @see java.applet.AppletContext
*/
public void browse(URI uri) throws IOException {
SecurityException securityException = null;
try {
checkAWTPermission();
checkExec();
} catch (SecurityException e) {
securityException = e;
}
checkActionSupport(Action.BROWSE);
if (uri == null) {
throw new NullPointerException();
}
if (securityException == null) {
peer.browse(uri);
return;
}
// Calling thread doesn't have necessary priviledges.
// Delegate to DesktopBrowse so that it can work in
// applet/webstart.
URL url = null;
try {
url = uri.toURL();
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Unable to convert URI to URL", e);
}
sun.awt.DesktopBrowse db = sun.awt.DesktopBrowse.getInstance();
if (db == null) {
// Not in webstart/applet, throw the exception.
throw securityException;
}
db.browse(url);
}Example 56
| Project: property-db-master File: Desktop.java View source code |
/** {@collect.stats}
* Launches the default browser to display a {@code URI}.
* If the default browser is not able to handle the specified
* {@code URI}, the application registered for handling
* {@code URIs} of the specified type is invoked. The application
* is determined from the protocol and path of the {@code URI}, as
* defined by the {@code URI} class.
* <p>
* If the calling thread does not have the necessary permissions,
* and this is invoked from within an applet,
* {@code AppletContext.showDocument()} is used. Similarly, if the calling
* does not have the necessary permissions, and this is invoked from within
* a Java Web Started application, {@code BasicService.showDocument()}
* is used.
*
* @param uri the URI to be displayed in the user default browser
* @throws NullPointerException if {@code uri} is {@code null}
* @throws UnsupportedOperationException if the current platform
* does not support the {@link Desktop.Action#BROWSE} action
* @throws IOException if the user default browser is not found,
* or it fails to be launched, or the default handler application
* failed to be launched
* @throws SecurityException if a security manager exists and it
* denies the
* <code>AWTPermission("showWindowWithoutWarningBanner")</code>
* permission, or the calling thread is not allowed to create a
* subprocess; and not invoked from within an applet or Java Web Started
* application
* @throws IllegalArgumentException if the necessary permissions
* are not available and the URI can not be converted to a {@code URL}
* @see java.net.URI
* @see java.awt.AWTPermission
* @see java.applet.AppletContext
*/
public void browse(URI uri) throws IOException {
SecurityException securityException = null;
try {
checkAWTPermission();
checkExec();
} catch (SecurityException e) {
securityException = e;
}
checkActionSupport(Action.BROWSE);
if (uri == null) {
throw new NullPointerException();
}
if (securityException == null) {
peer.browse(uri);
return;
}
// Calling thread doesn't have necessary priviledges.
// Delegate to DesktopBrowse so that it can work in
// applet/webstart.
URL url = null;
try {
url = uri.toURL();
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Unable to convert URI to URL", e);
}
sun.awt.DesktopBrowse db = sun.awt.DesktopBrowse.getInstance();
if (db == null) {
// Not in webstart/applet, throw the exception.
throw securityException;
}
db.browse(url);
}Example 57
| Project: SeanMovieManager-master File: SysUtil.java View source code |
public static int openUrlInBrowser(String url) {
if (!java.awt.Desktop.isDesktopSupported()) {
System.err.println("Desktop is not supported (fatal)");
return 1;
}
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
System.err.println("Desktop doesn't support the browse action (fatal)");
return 1;
}
try {
java.net.URI uri = new java.net.URI(url);
desktop.browse(uri);
} catch (Exception e) {
System.err.println(e.getMessage());
return 1;
}
return 0;
}Example 58
| Project: freedomotic-master File: MainWindow.java View source code |
//GEN-LAST:event_mnuPluginConfigureActionPerformed
private void mnuTutorialActionPerformed(java.awt.event.ActionEvent evt) {
//GEN-FIRST:event_mnuTutorialActionPerformed
String url = "http://freedomotic-user-manual.readthedocs.io/";
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
try {
// url is a string containing the URL
URI uri = new URI(url);
desktop.browse(uri);
} catch (IOExceptionURISyntaxException | ex) {
LOG.error(ex.getLocalizedMessage());
}
}
} else {
//open popup with link
JOptionPane.showMessageDialog(this, i18n.msg("goto") + url);
}
}Example 59
| Project: Icy-Kernel-master File: NetworkUtil.java View source code |
/**
* Open an URL in the default system browser
*/
public static boolean openBrowser(URI uri) {
if (uri == null)
return false;
final Desktop desktop = SystemUtil.getDesktop();
if ((desktop != null) && desktop.isSupported(Action.BROWSE)) {
try {
desktop.browse(uri);
return true;
} catch (IOException e) {
}
}
// not
return systemOpenBrowser(uri.toString());
}Example 60
| Project: musique-master File: DiscogsDialog.java View source code |
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1) {
ListSelectionModel selectionModel = lstReleases.getSelectionModel();
if (!selectionModel.isSelectionEmpty()) {
DiscogsReleaseListModel releaseModel = (DiscogsReleaseListModel) lstReleases.getModel();
ArtistRelease release = releaseModel.getEx(selectionModel.getMinSelectionIndex());
if (java.awt.Desktop.isDesktopSupported()) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
try {
desktop.browse(new URI("http://www.discogs.com/release/" + release.getId()));
} catch (Exception exc) {
}
}
}
}
}
}Example 61
| Project: panda-java-master File: PandaTVDanmu.java View source code |
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
java.net.URI uri = java.net.URI.create(latestVersionAddr);
// 获�当�系统桌�扩展
java.awt.Desktop dp = java.awt.Desktop.getDesktop();
// 判æ–系统桌é?¢æ˜¯å?¦æ”¯æŒ?è¦?执行的功能
if (dp.isSupported(java.awt.Desktop.Action.BROWSE)) {
//dp.edit(file);//  编辑文件
try {
dp.browse(uri);
} catch (IOException e1) {
e1.printStackTrace();
}
// 获�系统默认�览器打开链接
// dp.open(file);// 用默认方�打开文件
// dp.print(file);// 用打�机打�文件
}
}Example 62
| Project: PCBot-master File: AaimistersRoaches.java View source code |
public void openThread() {
if (java.awt.Desktop.isDesktopSupported()) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
log("Can't open thread. Something is conflicting.");
return;
}
try {
java.net.URI uri = new java.net.URI(url);
desktop.browse(uri);
} catch (Exception e) {
}
}
}Example 63
| Project: sweethome3d-master File: SweetHome3D.java View source code |
public boolean isWebBrowserSupported() {
if (OperatingSystem.isJavaVersionGreaterOrEqual("1.6")) {
try {
// Call Java SE 6 java.awt.Desktop isSupported(Desktop.Action.BROWSE)
// method by reflection to ensure Java SE 5 compatibility
Class<?> desktopClass = Class.forName("java.awt.Desktop");
Object desktopInstance = desktopClass.getMethod("getDesktop").invoke(null);
Class<?> desktopActionClass = Class.forName("java.awt.Desktop$Action");
Object desktopBrowseAction = desktopActionClass.getMethod("valueOf", String.class).invoke(null, "BROWSE");
if ((Boolean) desktopClass.getMethod("isSupported", desktopActionClass).invoke(desktopInstance, desktopBrowseAction)) {
return true;
}
} catch (Exception ex) {
}
}
// For other Java versions, let's support Mac OS X and Linux
return OperatingSystem.isMacOSX() || OperatingSystem.isLinux();
}Example 64
| Project: HomeNet.me-App-master File: HomeNetAppGui.java View source code |
//GEN-LAST:event_sendPacketButtonActionPerformed
private void menuHelpOnlineActionPerformed(java.awt.event.ActionEvent evt) {
if (!java.awt.Desktop.isDesktopSupported()) {
System.err.println("Desktop is not supported (fatal)");
// System.exit(1);
}
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
System.err.println("Desktop doesn't support the browse action (fatal)");
// System.exit(1);
}
try {
java.net.URI uri = new java.net.URI("http://homenet.me");
desktop.browse(uri);
} catch (Exception e) {
System.err.println(e.getMessage());
}
}Example 65
| Project: multibit-master File: ShowPreferencesPanel.java View source code |
private JPanel createButtonPanel() {
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
buttonPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, SystemColor.windowBorder));
buttonPanel.setOpaque(true);
buttonPanel.setBackground(ColorAndFontConstants.MID_BACKGROUND_COLOR);
buttonPanel.setComponentOrientation(ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
Action helpAction;
if (ComponentOrientation.LEFT_TO_RIGHT == ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())) {
helpAction = new HelpContextAction(controller, ImageLoader.HELP_CONTENTS_BIG_ICON_FILE, "multiBitFrame.helpMenuText", "multiBitFrame.helpMenuTooltip", "multiBitFrame.helpMenuText", HelpContentsPanel.HELP_PREFERENCES_URL);
} else {
helpAction = new HelpContextAction(controller, ImageLoader.HELP_CONTENTS_BIG_RTL_ICON_FILE, "multiBitFrame.helpMenuText", "multiBitFrame.helpMenuTooltip", "multiBitFrame.helpMenuText", HelpContentsPanel.HELP_PREFERENCES_URL);
}
HelpButton helpButton = new HelpButton(helpAction, controller);
helpButton.setText("");
helpButton.setToolTipText(controller.getLocaliser().getString("multiBitFrame.helpMenuTooltip"));
helpButton.setHorizontalAlignment(SwingConstants.LEADING);
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.gridx = 0;
constraints.gridy = 0;
constraints.weightx = 0.3;
constraints.weighty = 0.1;
constraints.gridwidth = 1;
constraints.gridheight = 1;
constraints.anchor = GridBagConstraints.LINE_START;
buttonPanel.add(helpButton, constraints);
ShowPreferencesSubmitAction submitAction = new ShowPreferencesSubmitAction(this.bitcoinController, this.exchangeController, this, ImageLoader.createImageIcon(ImageLoader.PREFERENCES_ICON_FILE), mainFrame);
MultiBitButton submitButton = new MultiBitButton(submitAction, controller);
buttonPanel.add(submitButton);
UndoPreferencesChangesSubmitAction undoChangesAction = new UndoPreferencesChangesSubmitAction(controller, ImageLoader.createImageIcon(ImageLoader.UNDO_ICON_FILE));
undoChangesButton = new MultiBitButton(undoChangesAction, controller);
buttonPanel.add(undoChangesButton);
constraints.fill = GridBagConstraints.NONE;
constraints.gridx = 1;
constraints.gridy = 0;
constraints.weightx = 0.1;
constraints.weighty = 1.0;
constraints.gridwidth = 1;
constraints.gridheight = 1;
constraints.anchor = GridBagConstraints.LINE_START;
buttonPanel.add(submitButton, constraints);
constraints.fill = GridBagConstraints.NONE;
constraints.gridx = 2;
constraints.gridy = 0;
constraints.weightx = 0.1;
constraints.weighty = 1.0;
constraints.gridwidth = 1;
constraints.gridheight = 1;
constraints.anchor = GridBagConstraints.LINE_START;
buttonPanel.add(undoChangesButton, constraints);
JPanel fill1 = new JPanel();
fill1.setOpaque(false);
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.gridx = 2;
constraints.gridy = 0;
constraints.weightx = 200;
constraints.weighty = 1;
constraints.gridwidth = 1;
constraints.gridheight = 1;
constraints.anchor = GridBagConstraints.LINE_END;
buttonPanel.add(fill1, constraints);
return buttonPanel;
}Example 66
| Project: TwoFactorBtcWallet-master File: ShowPreferencesPanel.java View source code |
private JPanel createButtonPanel() {
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
buttonPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, SystemColor.windowBorder));
buttonPanel.setOpaque(true);
buttonPanel.setBackground(ColorAndFontConstants.MID_BACKGROUND_COLOR);
buttonPanel.setComponentOrientation(ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
Action helpAction;
if (ComponentOrientation.LEFT_TO_RIGHT == ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())) {
helpAction = new HelpContextAction(controller, ImageLoader.HELP_CONTENTS_BIG_ICON_FILE, "multiBitFrame.helpMenuText", "multiBitFrame.helpMenuTooltip", "multiBitFrame.helpMenuText", HelpContentsPanel.HELP_PREFERENCES_URL);
} else {
helpAction = new HelpContextAction(controller, ImageLoader.HELP_CONTENTS_BIG_RTL_ICON_FILE, "multiBitFrame.helpMenuText", "multiBitFrame.helpMenuTooltip", "multiBitFrame.helpMenuText", HelpContentsPanel.HELP_PREFERENCES_URL);
}
HelpButton helpButton = new HelpButton(helpAction, controller);
helpButton.setText("");
helpButton.setToolTipText(controller.getLocaliser().getString("multiBitFrame.helpMenuTooltip"));
helpButton.setHorizontalAlignment(SwingConstants.LEADING);
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.gridx = 0;
constraints.gridy = 0;
constraints.weightx = 0.3;
constraints.weighty = 0.1;
constraints.gridwidth = 1;
constraints.gridheight = 1;
constraints.anchor = GridBagConstraints.LINE_START;
buttonPanel.add(helpButton, constraints);
ShowPreferencesSubmitAction submitAction = new ShowPreferencesSubmitAction(this.bitcoinController, this.exchangeController, this, ImageLoader.createImageIcon(ImageLoader.PREFERENCES_ICON_FILE), mainFrame);
MultiBitButton submitButton = new MultiBitButton(submitAction, controller);
buttonPanel.add(submitButton);
UndoPreferencesChangesSubmitAction undoChangesAction = new UndoPreferencesChangesSubmitAction(controller, ImageLoader.createImageIcon(ImageLoader.UNDO_ICON_FILE));
undoChangesButton = new MultiBitButton(undoChangesAction, controller);
buttonPanel.add(undoChangesButton);
constraints.fill = GridBagConstraints.NONE;
constraints.gridx = 1;
constraints.gridy = 0;
constraints.weightx = 0.1;
constraints.weighty = 1.0;
constraints.gridwidth = 1;
constraints.gridheight = 1;
constraints.anchor = GridBagConstraints.LINE_START;
buttonPanel.add(submitButton, constraints);
constraints.fill = GridBagConstraints.NONE;
constraints.gridx = 2;
constraints.gridy = 0;
constraints.weightx = 0.1;
constraints.weighty = 1.0;
constraints.gridwidth = 1;
constraints.gridheight = 1;
constraints.anchor = GridBagConstraints.LINE_START;
buttonPanel.add(undoChangesButton, constraints);
JPanel fill1 = new JPanel();
fill1.setOpaque(false);
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.gridx = 2;
constraints.gridy = 0;
constraints.weightx = 200;
constraints.weighty = 1;
constraints.gridwidth = 1;
constraints.gridheight = 1;
constraints.anchor = GridBagConstraints.LINE_END;
buttonPanel.add(fill1, constraints);
return buttonPanel;
}Example 67
| Project: all-inhonmodman-master File: Manager.java View source code |
/**
* Open specified website in the default browser. This method is using java
* Desktop API and therefore requires Java 1.6. Also, this operation might not
* be supported on all platforms.
*
* @param url url of the website to open
* @return true on success, false in case the operation is not supported on this platform
*/
public boolean openWebsite(String url) {
if (!java.awt.Desktop.isDesktopSupported()) {
logger.info("Opening websites is not supported");
return false;
}
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
logger.info("Opening websites is not supported");
return false;
}
try {
java.net.URI uri = new java.net.URI(url);
desktop.browse(uri);
} catch (Exception e) {
logger.error("Unable to open website: " + e.getMessage());
return false;
}
return true;
}Example 68
| Project: GCViewer-master File: UrlDisplayHelper.java View source code |
/**
* Returns <code>true</code> if the platform supports displaying of urls.
*
* @return <code>true</code> if displaying of urls is supported
*/
public static boolean displayUrlIsSupported() {
return Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Action.BROWSE);
}Example 69
| Project: activityinfo-master File: ImportTableModel.java View source code |
@Override
public String getColumnName(int columnIndex) {
switch(columnIndex) {
case ACTION_COLUMN:
return "Action";
case PARENT_COLUMN:
return "PARENT";
default:
return source.getAttributes().get(columnIndex - NUM_EXTRA_COLUMNS).getName().getLocalPart();
}
}Example 70
| Project: pcgen-deprecated-master File: DesktopBrowserLauncher.java View source code |
/**
* @return {@code true} if {@link #browse} is supported
* @see Desktop#isSupported(Action)
*/
static boolean isBrowseSupported() {
if (isBrowseSupported == null) {
isBrowseSupported = isDesktopSupported() && getDesktop().isSupported(Action.BROWSE);
}
return isBrowseSupported;
}Example 71
| Project: Scute-master File: HyperlinkAction.java View source code |
/**
* Factory method to create and return a HyperlinkAction for the given uri. Tries
* to guess the appropriate type from the uri. If uri is not null and has a
* scheme of mailto, create one of type Mail. In all other cases, creates one
* for BROWSE.
*
* @param uri to uri to create a HyperlinkAction for, maybe null.
* @return a HyperlinkAction for the given URI.
* @throws HeadlessException if {@link
* GraphicsEnvironment#isHeadless()} returns {@code true}
* @throws UnsupportedOperationException if the current platform doesn't support
* Desktop
*/
public static HyperlinkAction createHyperlinkAction(URI uri) {
Action type = isMailURI(uri) ? Action.MAIL : Action.BROWSE;
return createHyperlinkAction(uri, type);
}Example 72
| Project: SikuliX-2014-master File: HyperlinkAction.java View source code |
/**
* Factory method to create and return a HyperlinkAction for the given uri. Tries
* to guess the appropriate type from the uri. If uri is not null and has a
* scheme of mailto, create one of type Mail. In all other cases, creates one
* for BROWSE.
*
* @param uri to uri to create a HyperlinkAction for, maybe null.
* @return a HyperlinkAction for the given URI.
* @throws HeadlessException if {@link
* GraphicsEnvironment#isHeadless()} returns {@code true}
* @throws UnsupportedOperationException if the current platform doesn't support
* Desktop
*/
public static HyperlinkAction createHyperlinkAction(URI uri) {
Action type = isMailURI(uri) ? Action.MAIL : Action.BROWSE;
return createHyperlinkAction(uri, type);
}