Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ImageResolver.java')
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ImageResolver.java92
1 files changed, 0 insertions, 92 deletions
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ImageResolver.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ImageResolver.java
deleted file mode 100644
index f93431136..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ImageResolver.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. 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:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.internal.util.URIResolver;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.Element;
-
-/**
- * @author mengbo
- * @version 1.5
- */
-public class ImageResolver {
- /**
- *
- * @param element
- * @param attrName
- * @return
- */
- static String getResolvedURL(Element element, String attrName) {
- URIResolver resolver = null;
- if (element instanceof IDOMNode) {
- resolver = ((IDOMNode) element).getModel().getResolver();
- }
- if (null == resolver) {
- return null;
- }
- String src = DOMUtil.getAttributeIgnoreCase(element, attrName);
- if (src != null && src.length() > 0) {
- return resolver.getLocationByURI(src);
- }
- return null;
- }
-
- /**
- * given the element and an attribute name identifying the src of the image,
- * create a image.
- *
- * @param element
- * @param attrName
- * @return the new image
- */
- public static Image initializeImage(Element element, String attrName) {
- String url = getResolvedURL(element, attrName);
- if (url == null) {
- return null;
- }
- Image img = null;
- int colonIndex = url.indexOf(":"); //$NON-NLS-1$
- int slashIndex = url.indexOf("/"); //$NON-NLS-1$
- if (colonIndex != -1 && (slashIndex != -1 && colonIndex < slashIndex)) {
- //the url seems to have a protocol, so try to load it as a URL
- try {
- URL urlObj = new URL(url);
- ImageDescriptor imgDesc = ImageDescriptor.createFromURL(urlObj);
- img = imgDesc.createImage(false);
- } catch(MalformedURLException mfe) {
- //attempt to load as a file
- try {
- img = new Image(null, url);
- } catch(SWTException se) {
- //img remains null on return
- }
- } catch(SWTException se) {
- //img remains null on return
- }
- } else {
- //no protocol, so load it as a file
- try {
- img = new Image(null, url);
- } catch(SWTException se) {
- //img remains null on return
- }
- }
- return img;
- }
-}

Back to the top