diff options
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors')
12 files changed, 0 insertions, 1917 deletions
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/CSSDialogCellEditor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/CSSDialogCellEditor.java deleted file mode 100644 index f0c361eba..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/CSSDialogCellEditor.java +++ /dev/null @@ -1,63 +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.properties.celleditors; - -import org.eclipse.jface.preference.PreferenceManager; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.jsf.core.internal.tld.IJSFConstants; -import org.eclipse.jst.pagedesigner.commands.single.ChangeStyleCommand; -import org.eclipse.jst.pagedesigner.ui.dialogs.StyleDialog; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration; -import org.eclipse.wst.css.core.internal.util.declaration.CSSPropertyContext; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement; -import org.w3c.dom.css.ElementCSSInlineStyle; - -public class CSSDialogCellEditor extends EditableDialogCellEditor { - private IDOMElement _element; - - /** - * @param parent - */ - public CSSDialogCellEditor(Composite parent, IDOMElement element) { - super(parent); - _element = element; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control) - */ - protected Object openDialogBox(Control cellEditorWindow) { - ICSSStyleDeclaration styleDeclaration = (ICSSStyleDeclaration) ((ElementCSSInlineStyle) _element) - .getStyle(); - - PreferenceManager manager = new PreferenceManager(); - Shell shell = cellEditorWindow.getShell(); - - CSSPropertyContext context = new CSSPropertyContext(styleDeclaration); - StyleDialog dialog = new StyleDialog(shell, manager, _element, context); - if (dialog.open() == Window.OK) { - if (context.isModified()) { - ChangeStyleCommand c = new ChangeStyleCommand(_element, context); - c.execute(); - } - } - - String style = (_element == null ? null : _element - .getAttribute(IJSFConstants.ATTR_STYLE)); - return style == null ? "" : style; - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/CellEditorFactory.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/CellEditorFactory.java deleted file mode 100644 index f5f9dadd6..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/CellEditorFactory.java +++ /dev/null @@ -1,483 +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.properties.celleditors; - -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.TimeZone; -import java.util.TreeMap; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ComboDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StyleComboDialogField; -import org.eclipse.jst.pagedesigner.css2.CSSUtil; -import org.eclipse.jst.pagedesigner.jsp.core.IJSPCoreConstants; -import org.eclipse.jst.pagedesigner.meta.IAttributeCellEditorFactory; -import org.eclipse.jst.pagedesigner.meta.IAttributeDescriptor; -import org.eclipse.jst.pagedesigner.meta.IValueType; -import org.eclipse.jst.pagedesigner.ui.dialogfields.ContextableClasspathResourceButtonDialogField; -import org.eclipse.jst.pagedesigner.ui.dialogfields.ContextableResourceButtonDialogField; -import org.eclipse.jst.pagedesigner.ui.dialogfields.StyleButtonDialogField; -import org.eclipse.jst.pagedesigner.utils.StructuredModelUtil; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.w3c.dom.Element; - -/** - * - * @author mengbo - */ -public class CellEditorFactory implements IAttributeCellEditorFactory { - private static String[] CURRENCYCODES = { "AED", // United Arab Emirates, - // Dirhams //$NON-NLS-1$ - "AFA", // Afghanistan, Afghanis //$NON-NLS-1$ - "ALL", // Albania, Leke //$NON-NLS-1$ - "AMD", // Armenia, Drams //$NON-NLS-1$ - "ANG", // Netherlands Antilles, Guilders (also called Florins) - // //$NON-NLS-1$ - "AOA", // Angola, Kwanza //$NON-NLS-1$ - "ARS", // Argentina, Pesos //$NON-NLS-1$ - "AUD", // Australia, Dollars //$NON-NLS-1$ - "AWG", // Aruba, Guilders (also called Florins) //$NON-NLS-1$ - "AZM", // Azerbaijan, Manats //$NON-NLS-1$ - "BAM", // Bosnia and Herzegovina, Convertible Marka //$NON-NLS-1$ - "BBD", // Barbados, Dollars //$NON-NLS-1$ - "BDT", // Bangladesh, Taka //$NON-NLS-1$ - "BGN", // Bulgaria, Leva //$NON-NLS-1$ - "BHD", // Bahrain, Dinars //$NON-NLS-1$ - "BIF", // Burundi, Francs //$NON-NLS-1$ - "BMD", // Bermuda, Dollars //$NON-NLS-1$ - "BND", // Brunei Darussalam, Dollars //$NON-NLS-1$ - "BOB", // Bolivia, Bolivianos //$NON-NLS-1$ - "BRL", // Brazil, Brazil Real //$NON-NLS-1$ - "BSD", // Bahamas, Dollars //$NON-NLS-1$ - "BTN", // Bhutan, Ngultrum //$NON-NLS-1$ - "BWP", // Botswana, Pulas //$NON-NLS-1$ - "BYR", // Belarus, Rubles //$NON-NLS-1$ - "BZD", // Belize, Dollars //$NON-NLS-1$ - "CAD", // Canada, Dollars //$NON-NLS-1$ - "CDF", // Congo/Kinshasa, Congolese Francs //$NON-NLS-1$ - "CHF", // Switzerland, Francs //$NON-NLS-1$ - "CLP", // Chile, Pesos //$NON-NLS-1$ - "CNY", // China, Yuan Renminbi //$NON-NLS-1$ - "COP", // Colombia, Pesos //$NON-NLS-1$ - "CRC", // Costa Rica, Colones //$NON-NLS-1$ - "CSD", // Serbia, Dinars //$NON-NLS-1$ - "CUP", // Cuba, Pesos //$NON-NLS-1$ - "CVE", // Cape Verde, Escudos //$NON-NLS-1$ - "CYP", // Cyprus, Pounds //$NON-NLS-1$ - "CZK", // Czech Republic, Koruny //$NON-NLS-1$ - "DJF", // Djibouti, Francs //$NON-NLS-1$ - "DKK", // Denmark, Kroner //$NON-NLS-1$ - "DOP", // Dominican Republic, Pesos //$NON-NLS-1$ - "DZD", // Algeria, Algeria Dinars //$NON-NLS-1$ - "EEK", // Estonia, Krooni //$NON-NLS-1$ - "EGP", // Egypt, Pounds //$NON-NLS-1$ - "ERN", // Eritrea, Nakfa //$NON-NLS-1$ - "ETB", // Ethiopia, Birr //$NON-NLS-1$ - "EUR", // Euro Member Countries, Euro //$NON-NLS-1$ - "FJD", // Fiji, Dollars //$NON-NLS-1$ - "FKP", // Falkland Islands (Malvinas), Pounds //$NON-NLS-1$ - "GBP", // United Kingdom, Pounds //$NON-NLS-1$ - "GEL", // Georgia, Lari //$NON-NLS-1$ - "GGP", // Guernsey, Pounds //$NON-NLS-1$ - "GHC", // Ghana, Cedis //$NON-NLS-1$ - "GIP", // Gibraltar, Pounds //$NON-NLS-1$ - "GMD", // Gambia, Dalasi //$NON-NLS-1$ - "GNF", // Guinea, Francs //$NON-NLS-1$ - "GTQ", // Guatemala, Quetzales //$NON-NLS-1$ - "GYD", // Guyana, Dollars //$NON-NLS-1$ - "HKD", // Hong Kong, Dollars //$NON-NLS-1$ - "HNL", // Honduras, Lempiras //$NON-NLS-1$ - "HRK", // Croatia, Kuna //$NON-NLS-1$ - "HTG", // Haiti, Gourdes //$NON-NLS-1$ - "HUF", // Hungary, Forint //$NON-NLS-1$ - "IDR", // Indonesia, Rupiahs //$NON-NLS-1$ - "ILS", // Israel, New Shekels //$NON-NLS-1$ - "IMP", // Isle of Man, Pounds //$NON-NLS-1$ - "INR", // India, Rupees //$NON-NLS-1$ - "IQD", // Iraq, Dinars //$NON-NLS-1$ - "IRR", // Iran, Rials //$NON-NLS-1$ - "ISK", // Iceland, Kronur //$NON-NLS-1$ - "JEP", // Jersey, Pounds //$NON-NLS-1$ - "JMD", // Jamaica, Dollars //$NON-NLS-1$ - "JOD", // Jordan, Dinars //$NON-NLS-1$ - "JPY", // Japan, Yen //$NON-NLS-1$ - "KES", // Kenya, Shillings //$NON-NLS-1$ - "KGS", // Kyrgyzstan, Soms //$NON-NLS-1$ - "KHR", // Cambodia, Riels //$NON-NLS-1$ - "KMF", // Comoros, Francs //$NON-NLS-1$ - "KPW", // Korea (North), Won //$NON-NLS-1$ - "KRW", // Korea (South), Won //$NON-NLS-1$ - "KWD", // Kuwait, Dinars //$NON-NLS-1$ - "KYD", // Cayman Islands, Dollars //$NON-NLS-1$ - "KZT", // Kazakhstan, Tenge //$NON-NLS-1$ - "LAK", // Laos, Kips //$NON-NLS-1$ - "LBP", // Lebanon, Pounds //$NON-NLS-1$ - "LKR", // Sri Lanka, Rupees //$NON-NLS-1$ - "LRD", // Liberia, Dollars //$NON-NLS-1$ - "LSL", // Lesotho, Maloti //$NON-NLS-1$ - "LTL", // Lithuania, Litai //$NON-NLS-1$ - "LVL", // Latvia, Lati //$NON-NLS-1$ - "LYD", // Libya, Dinars //$NON-NLS-1$ - "MAD", // Morocco, Dirhams //$NON-NLS-1$ - "MDL", // Moldova, Lei //$NON-NLS-1$ - "MGA", // Madagascar, Ariary //$NON-NLS-1$ - "MKD", // Macedonia, Denars //$NON-NLS-1$ - "MMK", // Myanmar (Burma), Kyats //$NON-NLS-1$ - "MNT", // Mongolia, Tugriks //$NON-NLS-1$ - "MOP", // Macau, Patacas //$NON-NLS-1$ - "MRO", // Mauritania, Ouguiyas //$NON-NLS-1$ - "MTL", // Malta, Liri //$NON-NLS-1$ - "MUR", // Mauritius, Rupees //$NON-NLS-1$ - "MVR", // Maldives (Maldive Islands), Rufiyaa //$NON-NLS-1$ - "MWK", // Malawi, Kwachas //$NON-NLS-1$ - "MXN", // Mexico, Pesos //$NON-NLS-1$ - "MYR", // Malaysia, Ringgits //$NON-NLS-1$ - "MZM", // Mozambique, Meticais //$NON-NLS-1$ - "NAD", // Namibia, Dollars //$NON-NLS-1$ - "NGN", // Nigeria, Nairas //$NON-NLS-1$ - "NIO", // Nicaragua, Cordobas //$NON-NLS-1$ - "NOK", // Norway, Krone //$NON-NLS-1$ - "NPR", // Nepal, Nepal Rupees //$NON-NLS-1$ - "NZD", // New Zealand, Dollars //$NON-NLS-1$ - "OMR", // Oman, Rials //$NON-NLS-1$ - "PAB", // Panama, Balboa //$NON-NLS-1$ - "PEN", // Peru, Nuevos Soles //$NON-NLS-1$ - "PGK", // Papua New Guinea, Kina //$NON-NLS-1$ - "PHP", // Philippines, Pesos //$NON-NLS-1$ - "PKR", // Pakistan, Rupees //$NON-NLS-1$ - "PLN", // Poland, Zlotych //$NON-NLS-1$ - "PYG", // Paraguay, Guarani //$NON-NLS-1$ - "QAR", // Qatar, Rials //$NON-NLS-1$ - "ROL", // Romania, Lei //$NON-NLS-1$ - "RUB", // Russia, Rubles //$NON-NLS-1$ - "RWF", // Rwanda, Rwanda Francs //$NON-NLS-1$ - "SAR", // Saudi Arabia, Riyals //$NON-NLS-1$ - "SBD", // Solomon Islands, Dollars //$NON-NLS-1$ - "SCR", // Seychelles, Rupees //$NON-NLS-1$ - "SDD", // Sudan, Dinars //$NON-NLS-1$ - "SEK", // Sweden, Kronor //$NON-NLS-1$ - "SGD", // Singapore, Dollars //$NON-NLS-1$ - "SHP", // Saint Helena, Pounds //$NON-NLS-1$ - "SIT", // Slovenia, Tolars //$NON-NLS-1$ - "SKK", // Slovakia, Koruny //$NON-NLS-1$ - "SLL", // Sierra Leone, Leones //$NON-NLS-1$ - "SOS", // Somalia, Shillings //$NON-NLS-1$ - "SPL", // Seborga, Luigini //$NON-NLS-1$ - "SRD", // Suriname, Dollars //$NON-NLS-1$ - "STD", // S?o Tome and Principe, Dobras //$NON-NLS-1$ - "SVC", // El Salvador, Colones //$NON-NLS-1$ - "SYP", // Syria, Pounds //$NON-NLS-1$ - "SZL", // Swaziland, Emalangeni //$NON-NLS-1$ - "THB", // Thailand, Baht //$NON-NLS-1$ - "TJS", // Tajikistan, Somoni //$NON-NLS-1$ - "TMM", // Turkmenistan, Manats //$NON-NLS-1$ - "TND", // Tunisia, Dinars //$NON-NLS-1$ - "TOP", // Tonga, Pa'anga //$NON-NLS-1$ - "TRL", // Turkey, Liras [being phased out] //$NON-NLS-1$ - "TRY", // Turkey, New Lira //$NON-NLS-1$ - "TTD", // Trinidad and Tobago, Dollars //$NON-NLS-1$ - "TVD", // Tuvalu, Tuvalu Dollars //$NON-NLS-1$ - "TWD", // Taiwan, New Dollars //$NON-NLS-1$ - "TZS", // Tanzania, Shillings //$NON-NLS-1$ - "UAH", // Ukraine, Hryvnia //$NON-NLS-1$ - "UGX", // Uganda, Shillings //$NON-NLS-1$ - "USD", // United States of America, Dollars //$NON-NLS-1$ - "UYU", // Uruguay, Pesos //$NON-NLS-1$ - "UZS", // Uzbekistan, Sums //$NON-NLS-1$ - "VEB", // Venezuela, Bolivares //$NON-NLS-1$ - "VND", // Viet Nam, Dong //$NON-NLS-1$ - "VUV", // Vanuatu, Vatu //$NON-NLS-1$ - "WST", // Samoa, Tala //$NON-NLS-1$ - "XAF", // Communaut�� Financi��re Africaine BEAC, Francs - // //$NON-NLS-1$ - "XAG", // Silver, Ounces //$NON-NLS-1$ - "XAU", // Gold, Ounces //$NON-NLS-1$ - "XCD", // East Caribbean Dollars //$NON-NLS-1$ - "XDR", // International Monetary Fund (IMF) Special Drawing Rights - // //$NON-NLS-1$ - "XOF", // Communaut�� Financi��re Africaine BCEAO, Francs - // //$NON-NLS-1$ - "XPD", // Palladium Ounces //$NON-NLS-1$ - "XPF", // Comptoirs Fran?ais du Pacifique Francs //$NON-NLS-1$ - "XPT", // Platinum, Ounces //$NON-NLS-1$ - "YER", // Yemen, Rials //$NON-NLS-1$ - "ZAR", // South Africa, Rand //$NON-NLS-1$ - "ZMK", // Zambia, Kwacha //$NON-NLS-1$ - "ZWD" // Zimbabwe, Zimbabwe Dollars //$NON-NLS-1$ - }; - - public CellEditor createCellEditor(Composite parent, - IAttributeDescriptor attr, Element element) { - String type = attr.getValueType(); - - if (IValueType.ENUMERATED.equalsIgnoreCase(type)) { - Map map = new HashMap(attr.getOptions()); - String defaultValue = attr.getDefaultValue(); - if (defaultValue == null) { - return LabeledComboBoxCellEditor.newInstance(parent, map, - SWT.NONE); - } - return LabeledStyleComboCellEditor.newInstance(parent, map, - defaultValue, SWT.NONE); - } else if (IValueType.LOCALE.equalsIgnoreCase(type)) { - Map map = new HashMap(); - Locale[] locales = Locale.getAvailableLocales(); - for (int i = 0, size = locales.length; i < size; i++) { - map.put(locales[i].toString(), locales[i].toString()); - } - return LabeledComboBoxCellEditor.newInstance(parent, map, SWT.NONE); - } else if (IValueType.TIMEZONE.equalsIgnoreCase(type)) { - Map map = new HashMap(); - String[] ids = TimeZone.getAvailableIDs(); - for (int i = 0, size = ids.length; i < size; i++) { - map.put(ids[i], ids[i]); - } - return LabeledComboBoxCellEditor.newInstance(parent, map, SWT.NONE); - } else if (IValueType.RELATIVEPATH.equalsIgnoreCase(type) - || IValueType.WEBPATH.equalsIgnoreCase(type)) { - IProject project = getProject(element); - if (project != null) { - ResourceDialogCellEditor cellEditor = new ResourceDialogCellEditor( - parent); - cellEditor.setSuffixs(attr.getParameterByName( - IAttributeDescriptor.PARAMETER_SUFFIX).split(";")); - cellEditor - .setSeparator(attr - .getParameterByName(IAttributeDescriptor.PARAMETER_SEPARATOR)); - cellEditor.setProject(project); - cellEditor.setReferredFile(getFile(element)); - if ("".equalsIgnoreCase(cellEditor.getSeparator())) { - cellEditor.setResourceDescription(ResourceBoundle - .getString("FileCellEditor.Msg")); - } else { - cellEditor.setResourceDescription(ResourceBoundle - .getString("FileCellEditor.Msg1")); - } - if (IValueType.WEBPATH.equalsIgnoreCase(type)) { - cellEditor.setWebPath(true); - } - - if (IJSPCoreConstants.TAG_DIRECTIVE_INCLUDE.equals(element - .getLocalName()) - || IJSPCoreConstants.TAG_INCLUDE.equals(element - .getLocalName())) { - cellEditor.setTransformJSPURL(false); - } - return cellEditor; - } - } else if (IValueType.CLASSPATH_RESOURCE.equalsIgnoreCase(type)) { - return new LoadbundleSelectionCellEditor(parent, - getProject(element)); - } else if (IValueType.CSSID.equalsIgnoreCase(type)) { - // TODO: missing case? - } else if (IValueType.CSSCLASS.equalsIgnoreCase(type)) { - String cssclasses[] = CSSUtil.getCSSClasses(element - .getOwnerDocument()); - Map map = new HashMap(); - if (cssclasses != null) { - for (int i = 0; i < cssclasses.length; i++) { - map.put(cssclasses[i], cssclasses[i]); - } - } - return LabeledComboBoxCellEditor.newInstance(parent, map, SWT.NONE); - } else if (IValueType.BOOLEAN.equalsIgnoreCase(type)) { - String defaultValue = attr - .getParameterByName(IAttributeDescriptor.PARAMETER_DEFAULT); - Map booleanMap = new HashMap(); - booleanMap.put(Boolean.TRUE.toString(), Boolean.TRUE.toString()); - booleanMap.put(Boolean.FALSE.toString(), Boolean.FALSE.toString()); - if (defaultValue == null) { - return LabeledComboBoxCellEditor.newInstance(parent, - booleanMap, SWT.NONE); - } - return LabeledStyleComboCellEditor.newInstance(parent, - booleanMap, defaultValue, SWT.NONE); - } else if (IValueType.CSSSTYLE.equalsIgnoreCase(type)) { - String param = attr - .getParameterByName(IAttributeDescriptor.PARAMETER_STYLE); - if (!param.equalsIgnoreCase("STYLE")) { - return null; - } - CSSDialogCellEditor cellEditor = new CSSDialogCellEditor(parent, - (IDOMElement) element); - return cellEditor; - } else if (IValueType.NAMED_BOOLEAN.equalsIgnoreCase(type)) { - return NamedBooleanCellEditor.newInstance(parent, SWT.NONE, - (IDOMElement) element, attr); - } else if (IValueType.CURRENCYCODE.equalsIgnoreCase(type)) { - Map map = new HashMap(); - for (int i = 0, n = CURRENCYCODES.length; i < n; i++) { - map.put(CURRENCYCODES[i], CURRENCYCODES[i]); - } - - return LabeledComboBoxCellEditor.newInstance(parent, map, SWT.NONE); - } - - // if there is no type or type unknonw, then we just return null. and - // system will - // create default (text cell editor). - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.pagedesigner.meta.IAttributeCellEditorFactory#createDialogField(org.eclipse.jst.pagedesigner.meta.IAttributeDescriptor, - * org.w3c.dom.Element, org.w3c.dom.Element) - */ - public DialogField createDialogField(IAttributeDescriptor attr) { - String type = attr.getValueType(); - - if (IValueType.ENUMERATED.equalsIgnoreCase(type) - || IValueType.LOCALE.equalsIgnoreCase(type) - || IValueType.TIMEZONE.equalsIgnoreCase(type)) { - Map map = new HashMap(); - if (IValueType.ENUMERATED.equalsIgnoreCase(type)) { - map = attr.getOptions(); - } else if (IValueType.LOCALE.equalsIgnoreCase(type)) { - Locale[] locales = Locale.getAvailableLocales(); - for (int i = 0, size = locales.length; i < size; i++) { - map.put(locales[i].toString(), locales[i].toString()); - } - } else { - String[] ids = TimeZone.getAvailableIDs(); - for (int i = 0, size = ids.length; i < size; i++) { - map.put(ids[i], ids[i]); - } - } - if (map != null && !map.isEmpty()) { - String defaultValue = attr.getDefaultValue(); - if (defaultValue == null || "".equals(defaultValue)) { - attr - .getParameterByName(IAttributeDescriptor.PARAMETER_DEFAULT); - } - StyleComboDialogField field = new StyleComboDialogField( - SWT.NONE); - field.setDefaultValue(defaultValue); - field.setLabelText(attr.getLabelString()); - field.setEntryMap(new TreeMap(map)); - field.setRequired(attr.isRequired()); - field.setToolTip(attr.getDescription()); - return field; - } - // eles the config is incorrect. fall through, will return null. - } else if (IValueType.RELATIVEPATH.equalsIgnoreCase(type)) { - String param = attr.getTypeParameter(); - ContextableResourceButtonDialogField field = new ContextableResourceButtonDialogField(); - field.setLabelText(attr.getLabelString()); - if (param != null) { - field.setSuffixs(attr.getParameterByName( - IAttributeDescriptor.PARAMETER_SUFFIX).split(";")); - } - field.setResourceDescription(ResourceBoundle - .getString("FileCellEditor.Msg")); - field.setRequired(attr.isRequired()); - field.setToolTip(attr.getDescription()); - return field; - } else if (IValueType.WEBPATH.equalsIgnoreCase(type)) { - String param = attr.getTypeParameter(); - ContextableResourceButtonDialogField field = new ContextableResourceButtonDialogField(); - field.setLabelText(attr.getLabelString()); - if (param != null) { - field.setSuffixs(attr.getParameterByName( - IAttributeDescriptor.PARAMETER_SUFFIX).split(";")); - field - .setSeparator(attr - .getParameterByName(IAttributeDescriptor.PARAMETER_SEPARATOR)); - } - if ("".equalsIgnoreCase(field.getSeparator())) { - field.setResourceDescription(ResourceBoundle - .getString("FileCellEditor.Msg")); - } else { - field.setResourceDescription(ResourceBoundle - .getString("FileCellEditor.Msg1")); - } - field.setWebPath(true); - field.setRequired(attr.isRequired()); - field.setToolTip(attr.getDescription()); - return field; - } else if (IValueType.CLASSPATH_RESOURCE.equals(type)) { - ContextableClasspathResourceButtonDialogField field = new ContextableClasspathResourceButtonDialogField(); - field.setRequired(attr.isRequired()); - field.setToolTip(attr.getDescription()); - return field; - } else if (IValueType.BOOLEAN.equalsIgnoreCase(type)) { - String defaultValue = attr - .getParameterByName(IAttributeDescriptor.PARAMETER_DEFAULT); - StyleComboDialogField field = new StyleComboDialogField(SWT.NONE); - TreeMap map = new TreeMap(); - map.put("", ""); - map.put(Boolean.FALSE.toString(), Boolean.FALSE.toString()); - map.put(Boolean.TRUE.toString(), Boolean.TRUE.toString()); - field.setEntryMap(map); - field.setDefaultValue(defaultValue); - field.setLabelText(attr.getLabelString()); - field.setRequired(attr.isRequired()); - field.setToolTip(attr.getDescription()); - return field; - } else if (IValueType.CSSSTYLE.equalsIgnoreCase(type)) { - String param = attr - .getParameterByName(IAttributeDescriptor.PARAMETER_STYLE); - if (!"STYLE".equalsIgnoreCase(param)) { - return null; - } - StyleButtonDialogField field = new StyleButtonDialogField(); - field.setRequired(attr.isRequired()); - field.setToolTip(attr.getDescription()); - return field; - } else if (IValueType.CURRENCYCODE.equalsIgnoreCase(type)) { - ComboDialogField field = new ComboDialogField(SWT.NONE); - field.setLabelText(attr.getLabelString()); - field.setItems(CURRENCYCODES); - field.setRequired(attr.isRequired()); - field.setToolTip(attr.getDescription()); - return field; - } - - // if there is no type or type unknonw, then we just return null. and - // system will - // create default (text cell editor). - return null; - } - - private IProject getProject(Element element) { - if (element instanceof IDOMElement) { - IDOMModel model = ((IDOMElement) element).getModel(); - IFile file = StructuredModelUtil.getFileFor(model); - if (file != null) { - return file.getProject(); - } - } - return null; - } - - public String[] getSupportedValueTypes() { - return null; - } - - private IFile getFile(Element element) { - if (element instanceof IDOMElement) { - IDOMModel model = ((IDOMElement) element).getModel(); - IFile file = StructuredModelUtil.getFileFor(model); - return file; - } - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/CellEditorWrapper.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/CellEditorWrapper.java deleted file mode 100644 index 65ba99814..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/CellEditorWrapper.java +++ /dev/null @@ -1,358 +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.properties.celleditors; - -import java.text.MessageFormat; - -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ICellEditorListener; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Layout; -import org.eclipse.swt.widgets.Listener; - -/** - * CellEditorWrapper is a special cell editor, that wraps an existing cell - * editor by adding a small clickable button to end of it. - * - * Due to limitation of the CellEditor framework, this wrapping technology may - * resulting in some small inconvenience when change focus from the "wrapped" - * cell editor to the "added" button. - * - * This is an abstract class. Child class need override some methods. - * - * @author mengbo - */ -public abstract class CellEditorWrapper extends CellEditor { - /** - * The editor control. - */ - private Composite _editor; - - /** - * the wrapped cell editor - */ - private CellEditor _wrapped; - - /** - * The button. - */ - private Button _button; - - /** - * Internal class for laying out the dialog. - */ - private class DialogCellLayout extends Layout { - public void layout(Composite editor, boolean force) { - Rectangle bounds = editor.getClientArea(); - Point size = _button.computeSize(SWT.DEFAULT, SWT.DEFAULT, force); - // if (_wrapped != null) - _wrapped.getControl().setBounds(0, 0, bounds.width - size.x, - bounds.height); - _button.setBounds(bounds.width - size.x, 0, size.x, bounds.height); - } - - public Point computeSize(Composite editor, int wHint, int hHint, - boolean force) { - if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) - return new Point(wHint, hHint); - Point contentsSize = _wrapped.getControl().computeSize(SWT.DEFAULT, - SWT.DEFAULT, force); - Point buttonSize = _button.computeSize(SWT.DEFAULT, SWT.DEFAULT, - force); - // Just return the button width to ensure the button is not clipped - // if the label is long. - // The label will just use whatever extra width there is - Point result = new Point(buttonSize.x, Math.max(contentsSize.y, - buttonSize.y)); - return result; - } - } - - /** - * Default DialogCellEditor style - */ - private static final int defaultStyle = SWT.NONE; - - /** - * Creates a new dialog cell editor with no control - * - * @since 2.1 - */ - public CellEditorWrapper() { - setStyle(defaultStyle); - } - - /** - * Creates a new dialog cell editor parented under the given control. The - * cell editor value is <code>null</code> initially, and has no validator. - * - * @param parent - * the parent control - */ - protected CellEditorWrapper(Composite parent) { - this(parent, defaultStyle); - } - - /** - * Creates a new dialog cell editor parented under the given control. The - * cell editor value is <code>null</code> initially, and has no validator. - * - * @param parent - * the parent control - * @param style - * the style bits - * @since 2.1 - */ - protected CellEditorWrapper(Composite parent, int style) { - super(parent, style); - } - - /** - * Creates the button for this cell editor under the given parent control. - * <p> - * The default implementation of this framework method creates the button - * display on the right hand side of the dialog cell editor. Subclasses may - * extend or reimplement. - * </p> - * - * @param parent - * the parent control - * @return the new button control - */ - protected Button createButton(Composite parent) { - Button result = new Button(parent, SWT.DOWN); - result.setImage(getBindingImage()); - // result.setText("..."); //$NON-NLS-1$ - return result; - } - - /** - * Since createButton is called from constructor, so we could only let child - * class override this method to provide image. Rather than setting as - * property. - * - * @return - */ - protected abstract Image getBindingImage(); - - /** - * Creates the controls used to show the value of this cell editor. - * <p> - * The default implementation of this framework method creates a label - * widget, using the same font and background color as the parent control. - * </p> - * <p> - * Subclasses may reimplement. If you reimplement this method, you should - * also reimplement <code>updateContents</code>. - * </p> - * - * @param cell - * the control for this cell editor - */ - protected Control createContents(Composite cell) { - _wrapped = createWrappedCellEditor(cell); - if (_wrapped == null) { - _wrapped = new TextCellEditor(cell); - } - _wrapped.addListener(new ICellEditorListener() { - public void applyEditorValue() { - fireApplyEditorValue(); - } - - public void cancelEditor() { - fireCancelEditor(); - } - - public void editorValueChanged(boolean oldValidState, - boolean newValidState) { - fireEditorValueChanged(oldValidState, newValidState); - } - }); - _wrapped.addPropertyChangeListener(new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - // FIXME: - } - }); - - _wrapped.getControl().setVisible(true); - _wrapped.getControl().addListener(SWT.Hide, new Listener() { - public void handleEvent(Event event) { - Display.getCurrent().asyncExec(new Runnable() { - public void run() { - if (_wrapped != null && _wrapped.getControl() != null - && !_wrapped.getControl().isDisposed()) { - _wrapped.getControl().setVisible(true); - } else { - deactivate(); - } - } - }); - - } - }); - return _wrapped.getControl(); - } - - /** - * @param cell - * @return - */ - protected abstract CellEditor createWrappedCellEditor(Composite cell); - - /* - * (non-Javadoc) Method declared on CellEditor. - */ - protected Control createControl(Composite parent) { - Font font = parent.getFont(); - Color bg = parent.getBackground(); - - _editor = new Composite(parent, getStyle()); - _editor.setFont(font); - _editor.setBackground(bg); - _editor.setLayout(new DialogCellLayout()); - - createContents(_editor); - // updateContents(value); - - _button = createButton(_editor); - _button.setFont(font); - - _button.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent e) { - if (e.character == '\u001b') { // Escape - fireCancelEditor(); - } - } - }); - - _button.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - Object newValue = openDialogBox(_editor); - if (newValue != null) { - boolean newValidState = isCorrect(newValue); - if (newValidState) { - markDirty(); - doSetValue(newValue); - } else { - // try to insert the current value into the error - // message. - setErrorMessage(MessageFormat.format(getErrorMessage(), - new Object[] { newValue.toString() })); - } - fireApplyEditorValue(); - } - } - }); - - setValueValid(true); - - return _editor; - } - - /* - * (non-Javadoc) Method declared on CellEditor. The focus is set to the cell - * editor's button. - */ - protected void doSetFocus() { - if (_wrapped != null && _wrapped.getControl() != null - && !_wrapped.getControl().isDisposed()) { - _wrapped.setFocus(); - } else { - _button.setFocus(); - } - } - - /* - * (non-Javadoc) Method declared on CellEditor. - */ - protected Object doGetValue() { - return _wrapped.getValue(); - } - - /* - * (non-Javadoc) Method declared on CellEditor. - */ - protected void doSetValue(Object value) { - if (_wrapped != null) { - _wrapped.setValue(value); - } - } - - /** - * Opens a dialog box under the given parent control and returns the - * dialog's value when it closes, or <code>null</code> if the dialog was - * cancelled or no selection was made in the dialog. - * <p> - * This framework method must be implemented by concrete subclasses. It is - * called when the user has pressed the button and the dialog box must pop - * up. - * </p> - * - * @param cellEditorWindow - * the parent control cell editor's window so that a subclass can - * adjust the dialog box accordingly - * @return the selected value, or <code>null</code> if the dialog was - * cancelled or no selection was made in the dialog - */ - protected abstract Object openDialogBox(Control cellEditorWindow); - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.CellEditor#activate() - */ - public void activate() { - super.activate(); - _wrapped.activate(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.CellEditor#deactivate() - */ - public void deactivate() { - super.deactivate(); - // if (_wrapped != null) - // { - // _wrapped.deactivate(); - // } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.CellEditor#dispose() - */ - public void dispose() { - _wrapped.dispose(); - super.dispose(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/EditableDialogCellEditor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/EditableDialogCellEditor.java deleted file mode 100644 index 9a9c38599..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/EditableDialogCellEditor.java +++ /dev/null @@ -1,140 +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.properties.celleditors; - -import java.text.MessageFormat; - -import org.eclipse.jface.viewers.DialogCellEditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.FocusAdapter; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Text; - -/** - * @author mengbo - */ -public abstract class EditableDialogCellEditor extends DialogCellEditor { - private Text _text; - - /** - * - */ - public EditableDialogCellEditor() { - super(); - } - - /** - * @param parent - */ - public EditableDialogCellEditor(Composite parent) { - super(parent); - } - - /** - * @param parent - * @param style - */ - public EditableDialogCellEditor(Composite parent, int style) { - super(parent, style); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.DialogCellEditor#createContents(org.eclipse.swt.widgets.Composite) - */ - protected Control createContents(Composite cell) { - _text = new Text(cell, SWT.LEFT); - _text.setFont(cell.getFont()); - _text.setBackground(cell.getBackground()); - _text.addKeyListener(new KeyAdapter() { - // hook key pressed - see PR 14201 - public void keyPressed(KeyEvent e) { - keyReleaseOccured(e); - // disposed this cell editor - if ((getControl() == null) || getControl().isDisposed()) { - return; - } - } - }); - // when the text control has focus, the cellEditor will deactive even - // when you press the button. - // Add the follow codes enable switch to the button control. - _text.addFocusListener(new FocusAdapter() { - public void focusLost(FocusEvent e) { - boolean newValidState = isCorrect(_text.getText()); - if (newValidState) { - markDirty(); - doSetValue(_text.getText()); - } else { - // try to insert the current value into the error message. - setErrorMessage(MessageFormat.format(getErrorMessage(), - new Object[] { _text.getText().toString() })); - } - } - }); - - return _text; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.CellEditor#doSetFocus() - */ - protected void doSetFocus() { - _text.setFocus(); - _text.selectAll(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.DialogCellEditor#updateContents(java.lang.Object) - */ - protected void updateContents(Object value) { - if (_text == null || _text.isDisposed()) { - return; - } - - String text = "";//$NON-NLS-1$ - if (value != null) { - text = value.toString(); - } - _text.setText(text); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.CellEditor#keyReleaseOccured(org.eclipse.swt.events.KeyEvent) - */ - protected void keyReleaseOccured(KeyEvent keyEvent) { - if (keyEvent.character == '\r') { - boolean newValidState = isCorrect(_text.getText()); - if (newValidState) { - markDirty(); - doSetValue(_text.getText()); - } else { - // try to insert the current value into the error message. - setErrorMessage(MessageFormat.format(getErrorMessage(), - new Object[] { _text.getText().toString() })); - } - fireApplyEditorValue(); - } - super.keyReleaseOccured(keyEvent); - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/LabeledComboBoxCellEditor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/LabeledComboBoxCellEditor.java deleted file mode 100644 index 1bbaa02c6..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/LabeledComboBoxCellEditor.java +++ /dev/null @@ -1,149 +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.properties.celleditors; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.jface.viewers.ComboBoxCellEditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.sse.ui.internal.Logger; - -/** - * A simple ComboBoxCellEditor, which allow value and display string to be - * different. - * - * @author mengbo - */ -public class LabeledComboBoxCellEditor extends ComboBoxCellEditor { - private boolean _fSettingValue = false; - - private Object[] _values; - - public static LabeledComboBoxCellEditor newInstance(Composite parent, - Map valueLabelMap, int style) { - // we'll sort according to label. since that is what being show to user. - List list = new ArrayList(); - for (Iterator iter = valueLabelMap.keySet().iterator(); iter.hasNext();) { - Object key = iter.next(); - String label = (String) valueLabelMap.get(key); - list.add(new Object[] { key, label }); - } - // sort by label - Collections.sort(list, new Comparator() { - public int compare(Object o1, Object o2) { - String label1 = (String) ((Object[]) o1)[1]; - String label2 = (String) ((Object[]) o2)[1]; - return label1.compareTo(label2); - } - }); - Object[] values = new Object[list.size()]; - String[] labels = new String[list.size()]; - for (int i = 0, n = list.size(); i < n; i++) { - values[i] = ((Object[]) list.get(i))[0]; - labels[i] = (String) ((Object[]) list.get(i))[1]; - } - return new LabeledComboBoxCellEditor(parent, values, labels, style); - } - - /** - * @param parent - * @param items - */ - public LabeledComboBoxCellEditor(Composite parent, Object[] values, - String[] labels) { - this(parent, values, labels, SWT.NONE); - } - - /** - * @param parent - * @param items - * @param style - */ - public LabeledComboBoxCellEditor(Composite parent, Object[] values, - String[] labels, int style) { - super(parent, labels, style); - _values = values; - } - - protected Object doGetValue() { - // otherwise limits to set of valid values - Object index = super.doGetValue(); - int selection = -1; - if (index instanceof Integer) { - selection = ((Integer) index).intValue(); - } - if (selection >= 0) { - return _values[selection]; - } else if (getControl() instanceof CCombo) { - // retrieve the actual text as the list of valid items doesn't - // contain the value - return ((CCombo) getControl()).getText(); - } - return null; - } - - protected void doSetValue(Object value) { - if (_fSettingValue) { - return; - } - _fSettingValue = true; - if (value instanceof Integer) { - super.doSetValue(value); - } else { - String stringValue = value.toString(); - int selection = -1; - for (int i = 0; i < _values.length; i++) { - if (_values[i].equals(stringValue)) { - selection = i; - } - } - if (selection >= 0) { - super.doSetValue(new Integer(selection)); - } else { - super.doSetValue(new Integer(-1)); - if (getControl() instanceof CCombo - && !stringValue.equals(((CCombo) getControl()) - .getText())) { - // update the Text widget - ((CCombo) getControl()).setText(stringValue); - } - } - } - _fSettingValue = false; - } - - public void setItems(String[] newItems) { - if (getControl() == null || getControl().isDisposed()) { - Logger.log(Logger.ERROR, - "Attempted to update item list for disposed cell editor"); //$NON-NLS-1$ - return; - } - - // keep selection if possible - Object previousSelectedValue = getValue(); - super.setItems(newItems); - if (previousSelectedValue != null && getControl() instanceof CCombo) { - for (int i = 0; i < newItems.length; i++) { - if (newItems[i].equals(previousSelectedValue)) { - setValue(previousSelectedValue); - } - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/LabeledStyleComboCellEditor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/LabeledStyleComboCellEditor.java deleted file mode 100644 index a6fbb101b..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/LabeledStyleComboCellEditor.java +++ /dev/null @@ -1,135 +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.properties.celleditors; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.jst.jsf.common.ui.internal.utils.StyleCombo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.sse.ui.internal.Logger; - -public class LabeledStyleComboCellEditor extends StyleComboCellEditor { - private boolean _fSettingValue = false; - - private Object[] _values; - - public static LabeledStyleComboCellEditor newInstance(Composite parent, - Map valueLabelMap, String defaultValue, int style) { - // we'll sort according to label. since that is what being show to user. - List list = new ArrayList(); - for (Iterator iter = valueLabelMap.keySet().iterator(); iter.hasNext();) { - Object key = iter.next(); - String label = (String) valueLabelMap.get(key); - list.add(new Object[] { key, label }); - } - // sort by label - Collections.sort(list, new Comparator() { - public int compare(Object o1, Object o2) { - String label1 = (String) ((Object[]) o1)[1]; - String label2 = (String) ((Object[]) o2)[1]; - return label1.compareTo(label2); - } - }); - Object[] values = new Object[list.size()]; - String[] labels = new String[list.size()]; - for (int i = 0, n = list.size(); i < n; i++) { - values[i] = ((Object[]) list.get(i))[0]; - labels[i] = (String) ((Object[]) list.get(i))[1]; - } - return new LabeledStyleComboCellEditor(parent, values, labels, - defaultValue, style); - } - - /** - * @param parent - * @param items - * @param style - */ - public LabeledStyleComboCellEditor(Composite parent, Object[] values, - String[] labels, String defaultValue, int style) { - super(parent, labels, style); - StyleCombo combo = (StyleCombo) getControl(); - combo.setDefaultValue(defaultValue); - _values = values; - } - - protected Object doGetValue() { - // otherwise limits to set of valid values - Object index = super.doGetValue(); - int selection1 = -1; - if (index instanceof Integer) { - selection1 = ((Integer) index).intValue(); - } - if (selection1 >= 0) { - return _values[selection1]; - } else if (getControl() instanceof StyleCombo) { - // retrieve the actual text as the list of valid items doesn't - // contain the value - return ((StyleCombo) getControl()).getText(); - } - return null; - } - - protected void doSetValue(Object value) { - if (_fSettingValue) { - return; - } - _fSettingValue = true; - if (value instanceof Integer) { - super.doSetValue(value); - } else { - String stringValue = value.toString(); - int selection1 = -1; - for (int i = 0; i < _values.length; i++) { - if (_values[i].equals(stringValue)) { - selection1 = i; - } - } - if (selection1 >= 0) { - super.doSetValue(new Integer(selection1)); - } else { - super.doSetValue(new Integer(-1)); - if (getControl() instanceof StyleCombo - && !stringValue.equals(((StyleCombo) getControl()) - .getText())) { - // update the Text widget - ((StyleCombo) getControl()).setText(stringValue); - } - } - } - _fSettingValue = false; - } - - public void setItems(String[] newItems) { - if (getControl() == null || getControl().isDisposed()) { - Logger.log(Logger.ERROR, - "Attempted to update item list for disposed cell editor"); //$NON-NLS-1$ - return; - } - - // keep selection if possible - Object previousSelectedValue = getValue(); - super.setItems(newItems); - if (previousSelectedValue != null && getControl() instanceof StyleCombo) { - for (int i = 0; i < newItems.length; i++) { - if (newItems[i].equals(previousSelectedValue)) { - setValue(previousSelectedValue); - } - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/LoadbundleSelectionCellEditor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/LoadbundleSelectionCellEditor.java deleted file mode 100644 index a8659c38b..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/LoadbundleSelectionCellEditor.java +++ /dev/null @@ -1,57 +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.properties.celleditors; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.jsf.common.ui.IFileFolderConstants; -import org.eclipse.jst.jsf.common.ui.internal.dialogs.ResourceOnClasspathDialog; -import org.eclipse.jst.pagedesigner.properties.DesignerPropertyTool; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * @author mengbo - */ -public class LoadbundleSelectionCellEditor extends EditableDialogCellEditor { - private static final String[] PROPERTIES_FILES_SUFFIXS = new String[] { IFileFolderConstants.EXT_PROPERTIES }; - - private String _value; - - private IProject _project; - - /** - * @param parent - */ - public LoadbundleSelectionCellEditor(Composite parent, IProject project) { - super(parent); - _project = project; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control) - */ - protected Object openDialogBox(Control cellEditorWindow) { - ResourceOnClasspathDialog dialog = new ResourceOnClasspathDialog( - cellEditorWindow.getShell(), DesignerPropertyTool - .getJavaProject(_project)); - dialog.setTitle(ResourceBoundle.getString("FileCellEditor.Title")); - dialog.setSuffixs(PROPERTIES_FILES_SUFFIXS); - dialog.open(); - if (dialog.getResult() != null) { - _value = (String) dialog.getResult()[0]; - } - return _value; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/NamedBooleanCellEditor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/NamedBooleanCellEditor.java deleted file mode 100644 index 159e3ec13..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/NamedBooleanCellEditor.java +++ /dev/null @@ -1,38 +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.properties.celleditors; - -import org.eclipse.jst.pagedesigner.meta.IAttributeDescriptor; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement; - -/** - * @author mengbo - * @version 1.5 - */ -public class NamedBooleanCellEditor extends LabeledComboBoxCellEditor { - /** - * @param parent - * @param items - * @param style - */ - private NamedBooleanCellEditor(Composite parent, Object[] values, - String[] labels, int style) { - super(parent, values, labels, style); - } - - public static NamedBooleanCellEditor newInstance(Composite parent, - int style, IDOMElement element, IAttributeDescriptor attribute) { - String[] values = new String[] { "", attribute.getAttributeName() }; - return new NamedBooleanCellEditor(parent, values, values, style); - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/ResourceBoundle.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/ResourceBoundle.java deleted file mode 100644 index 7f00ed6df..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/ResourceBoundle.java +++ /dev/null @@ -1,38 +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.properties.celleditors; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * @author mengbo - * @version 1.5 - */ -public class ResourceBoundle { - private static final String BUNDLE_NAME = "org.eclipse.jst.pagedesigner.properties.celleditors.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - - private ResourceBoundle() { - // no external instantiation - } - - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/ResourceDialogCellEditor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/ResourceDialogCellEditor.java deleted file mode 100644 index 894ebd3a8..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/ResourceDialogCellEditor.java +++ /dev/null @@ -1,202 +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.properties.celleditors; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.jsf.common.ui.internal.dialogs.CommonResourceDialog; -import org.eclipse.jst.jsf.common.ui.internal.utils.PathUtil; -import org.eclipse.jst.jsf.common.ui.internal.utils.WebrootUtil; -import org.eclipse.jst.pagedesigner.utils.WebAppUtil; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - -/** - * @author mengbo - */ -public class ResourceDialogCellEditor extends EditableDialogCellEditor { - private IProject _project; - - private String[] _suffixs; - - private String _resourceDescription; - - private IFile _referredFile; - - private boolean _isWebPath = false; - - private boolean _needTransformJSPURL = true; - - private String _separator = ""; - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#DialogCellEditor() - */ - public ResourceDialogCellEditor() { - super(); - } - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#DialogCellEditor(Composite parent) - */ - public ResourceDialogCellEditor(Composite parent) { - super(parent); - } - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#DialogCellEditor(Composite parent, int style) - */ - public ResourceDialogCellEditor(Composite parent, int style) { - super(parent, style); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control) - */ - protected Object openDialogBox(Control cellEditorWindow) { - Shell shell = cellEditorWindow.getShell(); - int style = "".equals(_separator) ? SWT.NONE : SWT.MULTI | SWT.H_SCROLL - | SWT.V_SCROLL; - CommonResourceDialog dialog = new CommonResourceDialog(shell, _project, - style); - dialog.setTitle(ResourceBoundle.getString("FileCellEditor.Title")); - dialog.setSuffixs(_suffixs); - dialog.setResourceDescription(_resourceDescription); - if (dialog.open() == Window.OK) { - Object[] result = dialog.getResult(); - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < result.length; i++) { - IPath path = ((IFile) result[i]).getLocation(); - - IPath referredPath = null; - if (_referredFile != null) { - referredPath = _referredFile.getLocation(); - } else { - referredPath = _project.getLocation(); - } - - String newValue = null; - if (this._isWebPath) { - IFile selectedFile = ((IFile) result[i]); - newValue = WebrootUtil.getWebPath(selectedFile - .getFullPath()); - } else { - newValue = PathUtil.convertToRelativePath(path.toString(), - referredPath.toString()); - } - if (this._needTransformJSPURL) { - newValue = WebAppUtil.transformJSPURL(newValue, - this._referredFile); - } - buffer.append(newValue); - buffer.append(_separator); - } - if (buffer.length() > 0) { - return buffer.substring(0, buffer.length() - - _separator.length()); - } - } - return null; - } - - /** - * @param project - */ - public void setProject(IProject project) { - this._project = project; - } - - /** - * @return Returns the project. - */ - public IProject getProject() { - return _project; - } - - /** - * @return Returns the referredFile. - */ - public IFile getReferredFile() { - return _referredFile; - } - - /** - * @param referredFile - * The referredFile to set. - */ - public void setReferredFile(IFile referredFile) { - this._referredFile = referredFile; - } - - /** - * @return Returns the resourceDescription. - */ - public String getResourceDescription() { - return _resourceDescription; - } - - /** - * @param resourceDescription - * The resourceDescription to set. - */ - public void setResourceDescription(String resourceDescription) { - this._resourceDescription = resourceDescription; - } - - /** - * @return Returns the suffixs. - */ - public String[] getSuffixs() { - return _suffixs; - } - - /** - * @param suffixs - * The suffixs to set. - */ - public void setSuffixs(String[] suffixs) { - this._suffixs = suffixs; - } - - /** - * set some special path to web path instead of relative path - * - * @param isWebPath - */ - public void setWebPath(boolean isWebPath) { - this._isWebPath = isWebPath; - } - - public void setTransformJSPURL(boolean needTransform) { - this._needTransformJSPURL = needTransform; - } - - public String getSeparator() { - return _separator; - } - - public void setSeparator(String separator) { - this._separator = separator; - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/StyleComboCellEditor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/StyleComboCellEditor.java deleted file mode 100644 index 037f5cbd7..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/StyleComboCellEditor.java +++ /dev/null @@ -1,241 +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.properties.celleditors; - -import java.text.MessageFormat; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jst.jsf.common.ui.internal.utils.StyleCombo; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.FocusAdapter; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.TraverseEvent; -import org.eclipse.swt.events.TraverseListener; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -public class StyleComboCellEditor extends CellEditor { - /** - * The list of items to present in the combo box. - */ - private String[] items; - - /** - * The zero-based index of the selected item. - */ - int selection; - - /** - * The custom combo box control. - */ - StyleCombo comboBox; - - /** - * Default ComboBoxCellEditor style - */ - private static final int defaultStyle = SWT.NONE; - - public StyleComboCellEditor() { - setStyle(defaultStyle); - } - - public StyleComboCellEditor(Composite parent, String[] items) { - this(parent, items, defaultStyle); - } - - public StyleComboCellEditor(Composite parent, String[] items, int style) { - super(parent, style); - setItems(items); - } - - /** - * Returns the list of choices for the combo box - * - * @return the list of choices for the combo box - */ - public String[] getItems() { - return this.items; - } - - /** - * Sets the list of choices for the combo box - * - * @param items - * the list of choices for the combo box - */ - public void setItems(String[] items) { - Assert.isNotNull(items); - this.items = items; - populateComboBoxItems(); - } - - /* - * (non-Javadoc) Method declared on CellEditor. - */ - protected Control createControl(Composite parent) { - - comboBox = new StyleCombo(parent, getStyle()); - comboBox.setFont(parent.getFont()); - - comboBox.addKeyListener(new KeyAdapter() { - // hook key pressed - see PR 14201 - public void keyPressed(KeyEvent e) { - keyReleaseOccured(e); - } - }); - - comboBox.addSelectionListener(new SelectionAdapter() { - public void widgetDefaultSelected(SelectionEvent event) { - applyEditorValueAndDeactivate(); - } - - public void widgetSelected(SelectionEvent event) { - selection = comboBox.getSelectionIndex(); - } - }); - - comboBox.addTraverseListener(new TraverseListener() { - public void keyTraversed(TraverseEvent e) { - if (e.detail == SWT.TRAVERSE_ESCAPE - || e.detail == SWT.TRAVERSE_RETURN) { - e.doit = false; - } - } - }); - - comboBox.addFocusListener(new FocusAdapter() { - public void focusLost(FocusEvent e) { - StyleComboCellEditor.this.focusLost(); - } - }); - return comboBox; - } - - /** - * The <code>ComboBoxCellEditor</code> implementation of this - * <code>CellEditor</code> framework method returns the zero-based index - * of the current selection. - * - * @return the zero-based index of the current selection wrapped as an - * <code>Integer</code> - */ - protected Object doGetValue() { - return new Integer(selection); - } - - /* - * (non-Javadoc) Method declared on CellEditor. - */ - protected void doSetFocus() { - comboBox.setFocus(); - } - - /** - * The <code>ComboBoxCellEditor</code> implementation of this - * <code>CellEditor</code> framework method sets the minimum width of the - * cell. The minimum width is 10 characters if <code>comboBox</code> is - * not <code>null</code> or <code>disposed</code> eles it is 60 pixels - * to make sure the arrow button and some text is visible. The list of - * CCombo will be wide enough to show its longest item. - */ - public LayoutData getLayoutData() { - LayoutData layoutData = super.getLayoutData(); - if ((comboBox == null) || comboBox.isDisposed()) - layoutData.minimumWidth = 60; - else { - // make the comboBox 10 characters wide - GC gc = new GC(comboBox); - layoutData.minimumWidth = (gc.getFontMetrics() - .getAverageCharWidth() * 10) + 10; - gc.dispose(); - } - return layoutData; - } - - /** - * The <code>ComboBoxCellEditor</code> implementation of this - * <code>CellEditor</code> framework method accepts a zero-based index of - * a selection. - * - * @param value - * the zero-based index of the selection wrapped as an - * <code>Integer</code> - */ - protected void doSetValue(Object value) { - Assert.isTrue(comboBox != null && (value instanceof Integer)); - selection = ((Integer) value).intValue(); - comboBox.select(selection); - } - - /** - * Updates the list of choices for the combo box for the current control. - */ - private void populateComboBoxItems() { - if (comboBox != null && items != null) { - comboBox.removeAll(); - for (int i = 0; i < items.length; i++) - comboBox.add(items[i], i); - - setValueValid(true); - selection = 0; - } - } - - /** - * Applies the currently selected value and deactiavates the cell editor - */ - void applyEditorValueAndDeactivate() { - // must set the selection before getting value - selection = comboBox.getSelectionIndex(); - Object newValue = doGetValue(); - markDirty(); - boolean isValid = isCorrect(newValue); - setValueValid(isValid); - if (!isValid) { - // try to insert the current value into the error message. - setErrorMessage(MessageFormat.format(getErrorMessage(), - new Object[] { items[selection] })); - } - fireApplyEditorValue(); - deactivate(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.CellEditor#focusLost() - */ - protected void focusLost() { - if (isActivated()) { - applyEditorValueAndDeactivate(); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.CellEditor#keyReleaseOccured(org.eclipse.swt.events.KeyEvent) - */ - protected void keyReleaseOccured(KeyEvent keyEvent) { - if (keyEvent.character == '\u001b') { // Escape character - fireCancelEditor(); - } else if (keyEvent.character == '\t') { // tab key - applyEditorValueAndDeactivate(); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/messages.properties b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/messages.properties deleted file mode 100644 index 7399ca576..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/celleditors/messages.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2001, 2006 Oracle Corporation 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: -# Oracle Corporation - initial API and implementation -############################################################################### -FileCellEditor.Title=Select File -FileCellEditor.Msg=Select a file -FileCellEditor.Msg1=Select one or more files |