[38815] Style property value with expression language goes away in editing-time.
diff --git a/bundles/org.eclipse.jst.jsp.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.jst.jsp.ui/META-INF/MANIFEST.MF index ce27f7c..b432778 100644 --- a/bundles/org.eclipse.jst.jsp.ui/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.jst.jsp.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jst.jsp.ui; singleton:=true -Bundle-Version: 1.1.0 +Bundle-Version: 1.1.0.qualifier Bundle-Activator: org.eclipse.jst.jsp.ui.internal.JSPUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -56,5 +56,6 @@ org.eclipse.ltk.ui.refactoring, org.eclipse.wst.common.uriresolver, org.eclipse.ui.ide, - org.eclipse.wst.javascript.ui + org.eclipse.wst.javascript.ui, + org.eclipse.ui.views Eclipse-LazyStart: true
diff --git a/bundles/org.eclipse.jst.jsp.ui/plugin.xml b/bundles/org.eclipse.jst.jsp.ui/plugin.xml index c890426..8be368e 100644 --- a/bundles/org.eclipse.jst.jsp.ui/plugin.xml +++ b/bundles/org.eclipse.jst.jsp.ui/plugin.xml
@@ -618,7 +618,7 @@ class="org.eclipse.wst.css.ui.StructuredTextViewerConfigurationCSS" target="org.eclipse.jst.jsp.core.cssjspsource" /> <propertySheetConfiguration - class="org.eclipse.wst.css.ui.views.properties.CSSPropertySheetConfiguration" + class="org.eclipse.jst.jsp.css.ui.internal.views.properties.JSPedCSSPropertySheetConfiguration" target="org.eclipse.jst.jsp.core.cssjspsource" /> <provisionalConfiguration type="characterpairmatcher"
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/css/ui/internal/properties/JSPedCSSPropertySource.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/css/ui/internal/properties/JSPedCSSPropertySource.java new file mode 100644 index 0000000..09c7828 --- /dev/null +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/css/ui/internal/properties/JSPedCSSPropertySource.java
@@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jst.jsp.css.ui.internal.properties; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; +import org.eclipse.wst.css.ui.internal.properties.CSSPropertySource; + + + +public class JSPedCSSPropertySource extends CSSPropertySource { + + public JSPedCSSPropertySource(ICSSNode target) { + super(target); + } + + public void setPropertyValue(Object name, Object value) { + // workaround to avoid DOMException: if value contains jsp element, nothing happen. + String v = value.toString(); + if (v.indexOf("${") != -1 || v.indexOf("<%=") != -1){ + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + String title = JSPUIMessages.Title_InvalidValue; //$NON-NLS-1$ + String message = JSPUIMessages.Message_InvalidValue; //$NON-NLS-1$ + MessageDialog.openWarning(window.getShell(), title, message); + return; + } + super.setPropertyValue(name, value); + } +}
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/css/ui/internal/views/properties/JSPedCSSPropertySheetConfiguration.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/css/ui/internal/views/properties/JSPedCSSPropertySheetConfiguration.java new file mode 100644 index 0000000..7403816 --- /dev/null +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/css/ui/internal/views/properties/JSPedCSSPropertySheetConfiguration.java
@@ -0,0 +1,188 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jst.jsp.css.ui.internal.views.properties; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jst.jsp.css.ui.internal.properties.JSPedCSSPropertySource; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.progress.UIJob; +import org.eclipse.ui.views.properties.IPropertySheetPage; +import org.eclipse.ui.views.properties.IPropertySource; +import org.eclipse.ui.views.properties.IPropertySourceProvider; +import org.eclipse.ui.views.properties.PropertySheetPage; +import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; +import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; +import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; +import org.eclipse.wst.sse.ui.views.properties.PropertySheetConfiguration; +import org.eclipse.wst.xml.ui.internal.XMLUIMessages; + +public class JSPedCSSPropertySheetConfiguration extends PropertySheetConfiguration { + private class CSSPropertySheetRefreshAdapter implements INodeAdapter { + public boolean isAdapterForType(Object type) { + return false; + } + + public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { + if (fPropertySheetPage != null) { + getPropertiesRefreshJob().addPropertySheetPage(fPropertySheetPage); + } + } + } + + private class CSSPropertySourceProvider implements IPropertySourceProvider { + private IPropertySource fPropertySource = null; + private ICSSNode fSource = null; + + public IPropertySource getPropertySource(Object object) { + if (fSource != null && object.equals(fSource)) { + return fPropertySource; + } + + if (object instanceof ICSSNode) { + fSource = (ICSSNode)object; + fPropertySource = new JSPedCSSPropertySource(fSource); + } + else { + fSource = null; + fPropertySource = null; + } + return fPropertySource; + } + } + + private class PropertiesRefreshJob extends UIJob { + public static final int UPDATE_DELAY = 200; + + private Set propertySheetPages = null; + + public PropertiesRefreshJob() { + super(XMLUIMessages.JFaceNodeAdapter_1); + setSystem(true); + setPriority(Job.SHORT); + propertySheetPages = new HashSet(1); + } + + void addPropertySheetPage(IPropertySheetPage page) { + propertySheetPages.add(page); + schedule(UPDATE_DELAY); + } + + public IStatus runInUIThread(IProgressMonitor monitor) { + Object[] pages = propertySheetPages.toArray(); + propertySheetPages.clear(); + + for (int i = 0; i < pages.length; i++) { + PropertySheetPage page = (PropertySheetPage) pages[i]; + if (page.getControl() != null && !page.getControl().isDisposed()) { + page.refresh(); + } + } + + return Status.OK_STATUS; + } + } + + private PropertiesRefreshJob fPropertiesRefreshJob = null; + + IPropertySheetPage fPropertySheetPage; + + private IPropertySourceProvider fPropertySourceProvider = null; + + private INodeAdapter fRefreshAdapter = new CSSPropertySheetRefreshAdapter(); + + private INodeNotifier[] fSelectedNotifiers; + + /** + * Create new instance of CSSPropertySheetConfiguration + */ + public JSPedCSSPropertySheetConfiguration() { + // Must have empty constructor to createExecutableExtension + super(); + } + + public ISelection getInputSelection(IWorkbenchPart selectingPart, ISelection selection) { + // remove UI refresh adapters + if (fSelectedNotifiers != null) { + for (int i = 0; i < fSelectedNotifiers.length; i++) { + fSelectedNotifiers[i].removeAdapter(fRefreshAdapter); + } + fSelectedNotifiers = null; + } + + ISelection preferredSelection = super.getInputSelection(selectingPart, selection); + if (preferredSelection instanceof IStructuredSelection) { + Object[] selectedObjects = new Object[((IStructuredSelection) selection).size()]; + System.arraycopy(((IStructuredSelection) selection).toArray(), 0, selectedObjects, 0, selectedObjects.length); + for (int i = 0; i < selectedObjects.length; i++) { + if (selectedObjects[i] instanceof ICSSNode) { + ICSSNode node = (ICSSNode) selectedObjects[i]; + while (node.getNodeType() == ICSSNode.PRIMITIVEVALUE_NODE || node.getNodeType() == ICSSNode.STYLEDECLITEM_NODE) { + node = node.getParentNode(); + selectedObjects[i] = node; + } + } + } + + /* + * Add UI refresh adapters and remember notifiers for later + * removal + */ + if (selectedObjects.length > 0) { + List selectedNotifiers = new ArrayList(1); + for (int i = 0; i < selectedObjects.length; i++) { + if (selectedObjects[i] instanceof INodeNotifier) { + selectedNotifiers.add(selectedObjects[i]); + ((INodeNotifier) selectedObjects[i]).addAdapter(fRefreshAdapter); + } + } + fSelectedNotifiers = (INodeNotifier[]) selectedNotifiers.toArray(new INodeNotifier[selectedNotifiers.size()]); + } + preferredSelection = new StructuredSelection(selectedObjects); + } + return preferredSelection; + } + + PropertiesRefreshJob getPropertiesRefreshJob() { + if (fPropertiesRefreshJob == null) { + fPropertiesRefreshJob = new PropertiesRefreshJob(); + } + return fPropertiesRefreshJob; + } + + public IPropertySourceProvider getPropertySourceProvider(IPropertySheetPage page) { + if (fPropertySourceProvider == null) { + fPropertySourceProvider = new CSSPropertySourceProvider(); + fPropertySheetPage = page; + } + return fPropertySourceProvider; + } + + public void unconfigure() { + super.unconfigure(); + if (fSelectedNotifiers != null) { + for (int i = 0; i < fSelectedNotifiers.length; i++) { + fSelectedNotifiers[i].removeAdapter(fRefreshAdapter); + } + fSelectedNotifiers = null; + } + } +}
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIMessages.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIMessages.java index 2be7daa..d1c4d2d 100644 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIMessages.java +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIMessages.java
@@ -100,4 +100,6 @@ public static String JSPFContentSettingsPropertyPage_3; public static String JSPFContentSettingsPropertyPage_4; public static String ProjectJSPFContentSettingsPropertyPage_0; + public static String Title_InvalidValue; + public static String Message_InvalidValue; }
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIPluginResources.properties b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIPluginResources.properties index e3550d9..0ba3223 100644 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIPluginResources.properties +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIPluginResources.properties
@@ -80,3 +80,6 @@ JSPFContentSettingsPropertyPage_3=Content Type: JSPFContentSettingsPropertyPage_4=Enable specific setting: ProjectJSPFContentSettingsPropertyPage_0=The properties for J2EE Web projects act as "project" default to be looked up when no properties are specified for a particular JSP fragment file. +# CSS JSP +Title_InvalidValue=Invalid Value +Message_InvalidValue=Invalid property value.