Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigConverterIDFeatures.java')
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigConverterIDFeatures.java120
1 files changed, 120 insertions, 0 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigConverterIDFeatures.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigConverterIDFeatures.java
new file mode 100644
index 000000000..f9230adde
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigConverterIDFeatures.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation.
+ * 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:
+ * Gerry Kessler/Oracle - initial API and implementation
+ *
+ ********************************************************************************/
+package org.eclipse.jst.jsf.taglibprocessing.attributevalues;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager;
+import org.eclipse.jst.jsf.facesconfig.emf.ConverterType;
+import org.eclipse.jst.jsf.metadataprocessors.features.PossibleValue;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Meta-data processing feature representing an attribute value requiring a "converterid"
+ * @author Gerry Kessler - Oracle
+ */
+public class FacesConfigConverterIDFeatures extends FacesConfigIdentifierFeatures {
+
+ /**
+ * Faces converter classname
+ */
+ protected static final String CONVERTER = "javax.faces.convert.Converter"; //$NON-NLS-1$
+ /**
+ * Imagename to use when displaying converter
+ */
+ protected static final String IMAGE_NAME = "/icons/full/obj16/FacesConfig_Converter.gif"; //$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jst.jsf.taglibprocessing.internal.provisional.attributevalues.FacesConfigIdentifierFeatures#getElements(org.eclipse.jst.jsf.core.internal.provisional.jsfappconfig.JSFAppConfigManager)
+ */
+ protected List getElements(JSFAppConfigManager mgr) {
+ if (mgr != null)
+ return mgr.getConverters();
+ return new ArrayList(0);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jst.jsf.taglibprocessing.internal.provisional.attributevalues.FacesConfigIdentifierFeatures#getReturnType()
+ */
+ protected String getReturnType(){ return CONVERTER;}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jst.jsf.taglibprocessing.internal.provisional.attributevalues.FacesConfigIdentifierFeatures#getPossibleValueProposals(java.util.List)
+ */
+ protected List getPossibleValueProposals(List elements) {
+ List ret = new ArrayList();
+ Collections.sort(elements, new ConverterSorter());
+ for (Iterator it = elements.iterator();it.hasNext();){
+ ConverterType obj = (ConverterType)it.next();
+ if (obj.getConverterId() != null && obj.getConverterId().getTextContent() != null){
+ PossibleValue pv = createProposal(obj.getConverterId().getTextContent(), obj.getDisplayName(), obj.getDescription());
+ if (pv != null){
+ pv.setIcon(getImage());
+ ret.add(pv);
+ }
+ }
+ }
+ return ret;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jst.jsf.taglibprocessing.internal.provisional.attributevalues.FacesConfigIdentifierFeatures#getImageName()
+ */
+ protected String getImageName() {
+ return IMAGE_NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jst.jsf.taglibprocessing.internal.provisional.attributevalues.FacesConfigIdentifierFeatures#getMyValidationMessage(java.lang.String)
+ */
+ protected String getMyValidationMessage(String value) {
+ if (value == null || value.trim().equals("")) //$NON-NLS-1$
+ return Messages.FacesConfigConverterIDFeatures_converterid_empty;
+
+ return NLS.bind(Messages.FacesConfigIdentifierType_invalid_converter_id, new String[]{singleQuote(value)});
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jst.jsf.taglibprocessing.internal.provisional.attributevalues.FacesConfigIdentifierFeatures#getElementIDs(org.eclipse.jst.jsf.core.internal.provisional.jsfappconfig.JSFAppConfigManager)
+ */
+ protected List getElementIDs(JSFAppConfigManager mgr) {
+ List elements = getElements(mgr);
+ List ret = new ArrayList(elements.size());
+ for (Iterator it = elements.iterator();it.hasNext();){
+ ConverterType aType = (ConverterType)it.next();
+ if (aType.getConverterId() != null && aType.getConverterId().getTextContent() != null){
+ String id = aType.getConverterId().getTextContent();
+ if (id != null)
+ ret.add(id.trim());
+ }
+ }
+ return ret;
+ }
+
+ /**
+ *
+ * Converter ID Sorter - incomplete
+ */
+ class ConverterSorter implements Comparator {
+
+ public int compare(Object o1, Object o2) {
+ //TODO
+ return 0;
+
+ }
+
+ }
+}

Back to the top