Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 61599 Details for
Bug 161458
favicon support for repositories
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch for retrieving favicons
patch.txt (text/plain), 8.70 KB, created by
Leo Dos Santos
on 2007-03-21 15:50:33 EDT
(
hide
)
Description:
patch for retrieving favicons
Filename:
MIME Type:
Creator:
Leo Dos Santos
Created:
2007-03-21 15:50:33 EDT
Size:
8.70 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.tests >Index: src/org/eclipse/mylar/tests/misc/AllMiscTests.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tests/src/org/eclipse/mylar/tests/misc/AllMiscTests.java,v >retrieving revision 1.5 >diff -u -r1.5 AllMiscTests.java >--- src/org/eclipse/mylar/tests/misc/AllMiscTests.java 8 May 2006 23:31:37 -0000 1.5 >+++ src/org/eclipse/mylar/tests/misc/AllMiscTests.java 21 Mar 2007 19:49:09 -0000 >@@ -26,6 +26,7 @@ > // suite.addTestSuite(BugzillaSearchPluginTest.class); > suite.addTestSuite(AssertionsEnabledTest.class); > suite.addTestSuite(HypertextStructureBridgeTest.class); >+ suite.addTestSuite(GetFaviconForUrlTest.class); > //suite.addTestSuite(BugzillaStackTraceTest.class); > // $JUnit-END$ > return suite; >Index: .refactorings/2007/3/12/refactorings.history >=================================================================== >RCS file: .refactorings/2007/3/12/refactorings.history >diff -N .refactorings/2007/3/12/refactorings.history >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .refactorings/2007/3/12/refactorings.history 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,5 @@ >+<?xml version="1.0" encoding="utf-8" standalone="no"?> >+<session version="1.0"> >+<refactoring comment="Rename type 'org.eclipse.mylar.tests.misc.GetFaviconsForUrlText' to 'GetFaviconsForUrlTest' - Original project: 'org.eclipse.mylar.tests' - Original element: 'org.eclipse.mylar.tests.misc.GetFaviconsForUrlText' - Renamed element: 'org.eclipse.mylar.tests.misc.GetFaviconsForUrlTest' - Update references to refactored element - Update textual occurrences in comments and strings" description="Rename type 'GetFaviconsForUrlText'" flags="589830" id="org.eclipse.jdt.ui.rename.type" input="/src<org.eclipse.mylar.tests.misc{GetFaviconsForUrlText.java[GetFaviconsForUrlText" matchStrategy="1" name="GetFaviconsForUrlTest" qualified="false" references="true" similarDeclarations="false" stamp="1174496407717" textual="false" version="1.0"/> >+<refactoring comment="Rename compilation unit 'org.eclipse.mylar.tests.misc.GetFaviconsForUrlTest.java' to 'GetFaviconForUrlTest.java' - Original project: 'org.eclipse.mylar.tests' - Original element: 'org.eclipse.mylar.tests.misc.GetFaviconsForUrlTest.java' - Renamed element: 'org.eclipse.mylar.tests.misc.GetFaviconForUrlTest.java'" description="Rename compilation unit 'GetFaviconsForUrlTest.java'" flags="2" id="org.eclipse.jdt.ui.rename.compilationunit" input="/src<org.eclipse.mylar.tests.misc{GetFaviconsForUrlTest.java" name="GetFaviconForUrlTest.java" references="false" stamp="1174496520152" version="1.0"/> >+</session> >Index: .refactorings/2007/3/12/refactorings.index >=================================================================== >RCS file: .refactorings/2007/3/12/refactorings.index >diff -N .refactorings/2007/3/12/refactorings.index >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .refactorings/2007/3/12/refactorings.index 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,2 @@ >+1174496407717 Rename type 'GetFaviconsForUrlText' >+1174496520152 Rename compilation unit 'GetFaviconsForUrlTest.java' >Index: src/org/eclipse/mylar/tests/misc/GetFaviconForUrlTest.java >=================================================================== >RCS file: src/org/eclipse/mylar/tests/misc/GetFaviconForUrlTest.java >diff -N src/org/eclipse/mylar/tests/misc/GetFaviconForUrlTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/tests/misc/GetFaviconForUrlTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,60 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.tests.misc; >+ >+import java.net.MalformedURLException; >+ >+import org.eclipse.mylar.core.net.WebClientUtil; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.ImageData; >+ >+import junit.framework.TestCase; >+ >+/** >+ * @author Leo Dos Santos >+ */ >+public class GetFaviconForUrlTest extends TestCase { >+ >+ public void testMalformedUrl() { >+ boolean exceptionThrown = false; >+ try { >+ WebClientUtil.getFaviconForUrl("www.eclipse.org"); >+ } catch (MalformedURLException e) { >+ exceptionThrown = true; >+ } >+ assertTrue(exceptionThrown); >+ } >+ >+ public void testEclipseDotOrg() { >+ Image img = null; >+ try { >+ img = WebClientUtil.getFaviconForUrl("http://www.eclipse.org"); >+ } catch (MalformedURLException e) { >+ fail(); >+ } >+ assertNotNull(img); >+ ImageData data = img.getImageData(); >+ assertEquals(data.height, 16); >+ assertEquals(data.width, 16); >+ } >+ >+ public void testNoFavicon() { >+ Image img = null; >+ try { >+ img = WebClientUtil.getFaviconForUrl("http://help.eclipse.org/help32/index.jsp"); >+ } catch (MalformedURLException e) { >+ fail(); >+ } >+ assertNull(img); >+ } >+ >+} >#P org.eclipse.mylar >Index: src/org/eclipse/mylar/core/net/WebClientUtil.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar/src/org/eclipse/mylar/core/net/WebClientUtil.java,v >retrieving revision 1.8 >diff -u -r1.8 WebClientUtil.java >--- src/org/eclipse/mylar/core/net/WebClientUtil.java 19 Mar 2007 18:23:59 -0000 1.8 >+++ src/org/eclipse/mylar/core/net/WebClientUtil.java 21 Mar 2007 19:49:09 -0000 >@@ -12,7 +12,9 @@ > package org.eclipse.mylar.core.net; > > import java.net.InetSocketAddress; >+import java.net.MalformedURLException; > import java.net.Proxy; >+import java.net.URL; > import java.net.Proxy.Type; > > import org.apache.commons.httpclient.Credentials; >@@ -23,10 +25,15 @@ > import org.apache.commons.httpclient.params.HttpClientParams; > import org.apache.commons.httpclient.protocol.Protocol; > import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.swt.SWTException; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.ImageData; > > /** > * @author Mik Kersten > * @author Steffen Pingel >+ * @author Leo Dos Santos - getFaviconForUrl > */ > public class WebClientUtil { > >@@ -147,7 +154,7 @@ > .getInstance(), WebClientUtil.getPort(repositoryUrl)); > client.getHostConfiguration().setHost(WebClientUtil.getDomain(repositoryUrl), > WebClientUtil.getPort(repositoryUrl), acceptAllSsl); >- // Protocol.registerProtocol("https", acceptAllSsl); >+ Protocol.registerProtocol("https", acceptAllSsl); > } else { > client.getHostConfiguration().setHost(WebClientUtil.getDomain(repositoryUrl), > WebClientUtil.getPort(repositoryUrl)); >@@ -180,5 +187,33 @@ > } > return Proxy.NO_PROXY; > } >+ >+ /** >+ * @param repositoryUrl The URL of the web site including protocol. >+ * E.g. <code>http://foo.bar</code> or <code>https://foo.bar/baz</code> >+ * @return a 16*16 favicon, or null if no favicon found >+ * @throws MalformedURLException >+ */ >+ public static Image getFaviconForUrl(String repositoryUrl) throws MalformedURLException { >+ URL url = new URL(repositoryUrl); >+ >+ String host = url.getHost(); >+ String protocol = url.getProtocol(); >+ String favString = protocol + "://" + host + "/favicon.ico"; >+ >+ URL favUrl = new URL(favString); >+ try { >+ ImageDescriptor desc = ImageDescriptor.createFromURL(favUrl); >+ if (desc.getImageData() != null) { >+ if ((desc.getImageData().width != 16) && (desc.getImageData().height != 16)) { >+ ImageData data = desc.getImageData().scaledTo(16, 16); >+ return ImageDescriptor.createFromImageData(data).createImage(false); >+ } >+ } >+ return ImageDescriptor.createFromURL(favUrl).createImage(false); >+ } catch (SWTException e) { >+ return null; >+ } >+ } > > } >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar/META-INF/MANIFEST.MF,v >retrieving revision 1.248 >diff -u -r1.248 MANIFEST.MF >--- META-INF/MANIFEST.MF 17 Mar 2007 02:29:14 -0000 1.248 >+++ META-INF/MANIFEST.MF 21 Mar 2007 19:49:09 -0000 >@@ -4,7 +4,9 @@ > Bundle-SymbolicName: org.eclipse.mylar > Bundle-Version: 2.0.0.v20070316-1930 > Bundle-Vendor: Eclipse.org >-Require-Bundle: org.eclipse.core.runtime >+Require-Bundle: org.eclipse.core.runtime, >+ org.eclipse.swt, >+ org.eclipse.jface > Bundle-ClassPath: ., > lib-httpclient/commons-httpclient-3.0.1.jar, > lib-httpclient/commons-codec-1.3.jar,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 161458
:
52279
| 61599