package org.apache.taverna.activities.xpath.ui.servicedescription; | |
/* | |
* Licensed to the Apache Software Foundation (ASF) under one or more | |
* contributor license agreements. See the NOTICE file distributed with | |
* this work for additional information regarding copyright ownership. | |
* The ASF licenses this file to You under the Apache License, Version 2.0 | |
* (the "License"); you may not use this file except in compliance with | |
* the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
*/ | |
import java.awt.Color; | |
import java.net.URI; | |
import javax.swing.Icon; | |
import javax.swing.ImageIcon; | |
import org.apache.taverna.workbench.activityicons.ActivityIconSPI; | |
import org.apache.taverna.workbench.configuration.colour.ColourManager; | |
/** | |
* @author Sergejs Aleksejevs | |
*/ | |
public class XPathActivityIcon implements ActivityIconSPI { | |
private static final Color PROCESSOR_COLOUR = Color.decode("#E6FF5E"); | |
// --- LOCATIONS OF ICONS USED IN THE XPath ACTIVITY --- | |
/* from famfamfam-silk webjar | |
* http://www.famfamfam.com/lab/icons/silk/ | |
*/ | |
private static final String FAMFAMFAM_SILK_PATH = "/META-INF/resources/webjars/famfamfam-silk/1.3/icons/"; | |
public static final String XPATH_ACTIVITY_ICON = FAMFAMFAM_SILK_PATH + "page_white_code.png"; | |
public static final String XPATH_ACTIVITY_CONFIGURATION_PARSE_XML_ICON = FAMFAMFAM_SILK_PATH + "arrow_right.png"; | |
public static final String XML_TREE_ROOT_ICON = FAMFAMFAM_SILK_PATH + "page_white_code.png"; | |
public static final String XML_TREE_NODE_ICON = FAMFAMFAM_SILK_PATH + "tag.png"; | |
public static final String XML_TREE_ATTRIBUTE_ICON = FAMFAMFAM_SILK_PATH + "textfield.png"; | |
public static final String XML_TREE_EXPAND_ALL_ICON = FAMFAMFAM_SILK_PATH | |
+ "folder_explore.png"; | |
public static final String XML_TREE_COLLAPSE_ALL_ICON = FAMFAMFAM_SILK_PATH | |
+ "folder.png"; | |
public static final String XPATH_STATUS_OK_ICON = FAMFAMFAM_SILK_PATH + "accept.png"; | |
public static final String XPATH_STATUS_ERROR_ICON = FAMFAMFAM_SILK_PATH + "exclamation.png"; | |
public static final String XPATH_STATUS_UNKNOWN_ICON = FAMFAMFAM_SILK_PATH + "help.png"; | |
public static final String FOLD_ICON = FAMFAMFAM_SILK_PATH + "text_indent.png"; | |
public static final String UNFOLD_ICON = FAMFAMFAM_SILK_PATH + "text_indent_remove.png"; | |
// ------ | |
private static ImageIcon icon; | |
public int canProvideIconScore(URI activityType) { | |
if (XPathTemplateService.ACTIVITY_TYPE.equals(activityType)) | |
return DEFAULT_ICON + 1; | |
else | |
return NO_ICON; | |
} | |
public Icon getIcon(URI activityType) { | |
return getXPathActivityIcon(); | |
} | |
public static Icon getXPathActivityIcon() { | |
if (icon == null) { | |
synchronized (XPathActivityIcon.class) { | |
if (icon == null) { | |
try { | |
icon = new ImageIcon( | |
XPathActivityIcon.class.getResource(XPATH_ACTIVITY_ICON)); | |
} catch (NullPointerException e) { | |
/* icon wasn't found - do nothing, but no icon will be available */ | |
} | |
} | |
} | |
} | |
return (icon); | |
} | |
public static Icon getIconById(String iconID) { | |
try { | |
return (new ImageIcon(XPathActivityIcon.class.getResource(iconID))); | |
} catch (NullPointerException e) { | |
// requested icon wasn't found - just return null | |
return (null); | |
} | |
} | |
public void setColourManager(ColourManager colourManager) { | |
colourManager.setPreferredColour(XPathTemplateService.ACTIVITY_TYPE.toString(), PROCESSOR_COLOUR); | |
} | |
} |