diff options
author | pmoogk | 2007-11-07 16:30:37 +0000 |
---|---|---|
committer | pmoogk | 2007-11-07 16:30:37 +0000 |
commit | 2e81eaa902d234c1b4d47d0a0e5e415015a263af (patch) | |
tree | 72913a9b66b0dcb0ccc4daccf57f6c384af4bd58 /bundles | |
parent | 3aca1fd10a4f80aaffd7c91d9e835eacc51cf69b (diff) | |
download | webtools.webservices-2e81eaa902d234c1b4d47d0a0e5e415015a263af.tar.gz webtools.webservices-2e81eaa902d234c1b4d47d0a0e5e415015a263af.tar.xz webtools.webservices-2e81eaa902d234c1b4d47d0a0e5e415015a263af.zip |
[196997] Initial code drop of service policy plugins
Diffstat (limited to 'bundles')
8 files changed, 144 insertions, 41 deletions
diff --git a/bundles/org.eclipse.wst.ws.service.policy/plugin.xml b/bundles/org.eclipse.wst.ws.service.policy/plugin.xml index 2de7e53aa..f9140e9aa 100644 --- a/bundles/org.eclipse.wst.ws.service.policy/plugin.xml +++ b/bundles/org.eclipse.wst.ws.service.policy/plugin.xml @@ -7,8 +7,6 @@ <extension point="org.eclipse.wst.ws.service.policy.servicepolicy"> <servicePolicy> - <loadListener class="org.eclipse.wst.ws.service.internal.policy.migration.MigrateWSIpreferencesLoadListener"/> - <enumeration id="org.eclipse.wst.service.policy.booleanEnum" default="org.eclipse.wst.true"> <item id="org.eclipse.wst.true" @@ -45,7 +43,7 @@ <!-- CONTEXT_ID PSPW0001 for the Service Policies WS-I Preferences category --> <descriptor longName="%PREFERENCE_SERVICEPOLICIES_CONTAINER_WSI_COMPLIANCE" iconPath="icons/full/obj16/wsicat.gif" contextHelpId="org.eclipse.wst.ws.service.policy.ui.PSPW0001"/> </policy> - <policy id="org.eclipse.wst.ws.service.policy.ui.servicepols.wsiprofilecomp.wsiap" parentPolicyId="org.eclipse.wst.ws.service.policy.ui.servicepols.wsiprofilecomp" enumListId="org.eclipse.wst.service.policy.suggestionEnum" defaultEnumId="org.eclipse.wst.sug.suggest" mutable="true"> + <policy id="org.eclipse.wst.ws.service.policy.ui.servicepols.wsiprofilecomp.wsiap" parentPolicyId="org.eclipse.wst.ws.service.policy.ui.servicepols.wsiprofilecomp" enumListId="org.eclipse.wst.service.policy.suggestionEnum" defaultEnumId="org.eclipse.wst.sug.suggest"> <!-- CONTEXT_ID PSPW0002 for the Service Policies WS-I AP 1.0 Preference --> <descriptor longName="%LABEL_WSI_AP" iconPath="icons/full/obj16/wsicat_child.gif" contextHelpId="org.eclipse.wst.ws.service.policy.ui.PSPW0002"/> <relationship enumList="org.eclipse.wst.sug.suggest"> @@ -57,7 +55,7 @@ itemList="org.eclipse.wst.sug.require"/> </relationship> </policy> - <policy id="org.eclipse.wst.ws.service.policy.ui.servicepols.wsiprofilecomp.wsissbp" parentPolicyId="org.eclipse.wst.ws.service.policy.ui.servicepols.wsiprofilecomp" enumListId="org.eclipse.wst.service.policy.suggestionEnum" defaultEnumId="org.eclipse.wst.sug.suggest" mutable="true"> + <policy id="org.eclipse.wst.ws.service.policy.ui.servicepols.wsiprofilecomp.wsissbp" parentPolicyId="org.eclipse.wst.ws.service.policy.ui.servicepols.wsiprofilecomp" enumListId="org.eclipse.wst.service.policy.suggestionEnum" defaultEnumId="org.eclipse.wst.sug.suggest"> <!-- CONTEXT_ID PSPW0003 for the Service Policies WS-I SSBP 1.0 Preference --> <descriptor longName="%LABEL_WSI_SSBP" iconPath="icons/full/obj16/wsicat_child.gif" contextHelpId="org.eclipse.wst.ws.service.policy.ui.PSPW0003"/> </policy> diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/PolicyStateImpl.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/PolicyStateImpl.java index e89a0885e..a1477286a 100644 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/PolicyStateImpl.java +++ b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/PolicyStateImpl.java @@ -53,6 +53,9 @@ public class PolicyStateImpl implements IPolicyState public void commitChanges() { + // We don't do anything if this policy is not mutable. + if( !mutable ) return; + IEclipsePreferences preferences = null; if( project == null ) @@ -102,6 +105,8 @@ public class PolicyStateImpl implements IPolicyState public void discardChanges() { + if( !mutable ) return; + for( TableEntry entry : table.values() ) { entry.value = null; @@ -172,6 +177,8 @@ public class PolicyStateImpl implements IPolicyState public void putDefaultValue(String key, String defaultValue) { + if( !mutable ) return; + TableEntry entry = table.get( key ); if( entry == null ) @@ -185,6 +192,8 @@ public class PolicyStateImpl implements IPolicyState public void putValue(String key, String value) { + if( !mutable ) return; + TableEntry entry = table.get( key ); if( entry == null ) diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyImpl.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyImpl.java index 91db03290..082780534 100644 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyImpl.java +++ b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyImpl.java @@ -161,15 +161,16 @@ public class ServicePolicyImpl implements IServicePolicy public IPolicyState getPolicyState( IProject project ) { - PolicyStateImpl policyState = projectPolicyStates.get( project ); + PolicyStateImpl projectPolicyState = projectPolicyStates.get( project ); - if( policyState == null ) + if( projectPolicyState == null ) { - policyState = new PolicyStateImpl( this, project ); - projectPolicyStates.put( project, policyState ); + projectPolicyState = new PolicyStateImpl( this, project ); + projectPolicyState.internalSetMutable( policyState.isMutable() ); + projectPolicyStates.put( project, projectPolicyState ); } - return policyState; + return projectPolicyState; } public IPolicyStateEnum getPolicyStateEnum() diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyPlatformImpl.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyPlatformImpl.java index 389d0a1eb..702d4a8fc 100644 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyPlatformImpl.java +++ b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyPlatformImpl.java @@ -106,6 +106,7 @@ public class ServicePolicyPlatformImpl { ((PolicyStateImpl)policy.getPolicyState( project )).commitChanges(); } + } public void discardChanges() diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyRegistry.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyRegistry.java index fbfa7276e..a6e8891a8 100644 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyRegistry.java +++ b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/ServicePolicyRegistry.java @@ -213,6 +213,15 @@ public class ServicePolicyRegistry DescriptorImpl descriptor = null; List<UnresolvedRelationship> relationships = new Vector<UnresolvedRelationship>(); + // If the mutable attribute was not specified and the enumListId attribute + // attribute was specified then this policy should be mutable, since + // it doesn't make sense to associate state with a policy that is not + // changeable. + if( mutableValue == null && enumListId != null ) + { + mutable = true; + } + try { for( IConfigurationElement policyElement : policyElements ) diff --git a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/migration/MigrateWSIpreferencesLoadListener.java b/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/migration/MigrateWSIpreferencesLoadListener.java deleted file mode 100644 index e37ab8469..000000000 --- a/bundles/org.eclipse.wst.ws.service.policy/src/org/eclipse/wst/ws/service/internal/policy/migration/MigrateWSIpreferencesLoadListener.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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 - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20071105 196997 pmoogk@ca.ibm.com - Peter Moogk - *******************************************************************************/ -package org.eclipse.wst.ws.service.internal.policy.migration; - -import org.eclipse.wst.ws.service.policy.listeners.IPolicyPlatformLoadListener; - -public class MigrateWSIpreferencesLoadListener implements IPolicyPlatformLoadListener -{ - public void load() - { - // We need to check to see if the user has set any WSI preferences. - // If not we want to default WSI preferences to any old WSI preferences that - // have been set. - - //IEclipsePreferences preferences = new InstanceScope().getNode( ServicePolicyActivator.PLUGIN_ID ); - //IServicePolicy apPolicy = platform.getServicePolicy( "org.eclipse.wst.ws.service.policy.ui.servicepols.wsiprofilecomp.wsiap" ); - //IPolicyStateEnum apState = apPolicy.getPolicyStateEnum(); - //IServicePolicy ssbpPolicy = platform.getServicePolicy( "org.eclipse.wst.ws.service.policy.ui.servicepols.wsiprofilecomp.wsissbp" ); - } -} diff --git a/bundles/org.eclipse.wst.ws/plugin.xml b/bundles/org.eclipse.wst.ws/plugin.xml index cd686e35d..45e76fe2c 100644 --- a/bundles/org.eclipse.wst.ws/plugin.xml +++ b/bundles/org.eclipse.wst.ws/plugin.xml @@ -40,5 +40,10 @@ default-charset="UTF-8" file-extensions="wsil"/> </extension> - + + <extension point="org.eclipse.wst.ws.service.policy.servicepolicy"> + <servicePolicy> + <loadListener class="org.eclipse.wst.ws.internal.preferences.MigrateWSIpreferencesLoadListener"/> + </servicePolicy> + </extension> </plugin> diff --git a/bundles/org.eclipse.wst.ws/src/org/eclipse/wst/ws/internal/preferences/MigrateWSIpreferencesLoadListener.java b/bundles/org.eclipse.wst.ws/src/org/eclipse/wst/ws/internal/preferences/MigrateWSIpreferencesLoadListener.java new file mode 100644 index 000000000..3cd876278 --- /dev/null +++ b/bundles/org.eclipse.wst.ws/src/org/eclipse/wst/ws/internal/preferences/MigrateWSIpreferencesLoadListener.java @@ -0,0 +1,111 @@ +/******************************************************************************* + * Copyright (c) 2007 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 + * yyyymmdd bug Email and other contact information + * -------- -------- ----------------------------------------------------------- + * 20071105 196997 pmoogk@ca.ibm.com - Peter Moogk + *******************************************************************************/ +package org.eclipse.wst.ws.internal.preferences; + +import org.eclipse.core.runtime.Preferences; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.wst.ws.internal.plugin.WSPlugin; +import org.eclipse.wst.ws.service.policy.IPolicyState; +import org.eclipse.wst.ws.service.policy.IServicePolicy; +import org.eclipse.wst.ws.service.policy.ServicePolicyActivator; +import org.eclipse.wst.ws.service.policy.ServicePolicyPlatform; +import org.eclipse.wst.ws.service.policy.listeners.IPolicyPlatformLoadListener; + +public class MigrateWSIpreferencesLoadListener implements IPolicyPlatformLoadListener +{ + private static final String[] ENUM_ID_VALUES = { "org.eclipse.wst.sug.require", "org.eclipse.wst.sug.suggest", "org.eclipse.wst.sug.ignore"}; + private static final String[] CONTEXT_IDS = { PersistentWSIContext.STOP_NON_WSI, PersistentWSIContext.WARN_NON_WSI, PersistentWSIContext.IGNORE_NON_WSI }; + + public void load() + { + // We need to check to see if the user has set any WSI preferences. + // If not we want to default WSI preferences to any old WSI preferences that + // have been set. + + IEclipsePreferences preferences = new InstanceScope().getNode( ServicePolicyActivator.PLUGIN_ID ); + String apValue = preferences.get( "org.eclipse.wst.ws.service.policy.ui.servicepols.wsiprofilecomp.wsiap.value", null ); + String ssbpValue = preferences.get( "org.eclipse.wst.ws.service.policy.ui.servicepols.wsiprofilecomp.wsissbp.value", null ); + Preferences oldPrefs = WSPlugin.getInstance().getPluginPreferences(); + String[] oldPropNames = oldPrefs.propertyNames(); + + if( apValue == null ) + { + ServicePolicyPlatform platform = ServicePolicyPlatform.getInstance(); + IServicePolicy apPolicy = platform.getServicePolicy( "org.eclipse.wst.ws.service.policy.ui.servicepols.wsiprofilecomp.wsiap" ); + IPolicyState apState = apPolicy.getPolicyState(); + + if( indexOfString( "nonWSIAPCompliance", oldPropNames ) != -1 ) + { + // We have an old AP value so we will use it's value as the default for settings. + String oldApValue = oldPrefs.getString( "nonWSIAPCompliance" ); + int oldApIndex = indexOfString( oldApValue, CONTEXT_IDS ); + String newApValue = null; + + if( oldApIndex < ENUM_ID_VALUES.length ) + { + newApValue = ENUM_ID_VALUES[oldApIndex]; + } + + if( newApValue != null ) + { + apState.putDefaultValue( "value", newApValue ); + } + } + } + + if( ssbpValue == null ) + { + ServicePolicyPlatform platform = ServicePolicyPlatform.getInstance(); + IServicePolicy ssbpPolicy = platform.getServicePolicy( "org.eclipse.wst.ws.service.policy.ui.servicepols.wsiprofilecomp.wsissbp" ); + IPolicyState ssbpState = ssbpPolicy.getPolicyState(); + + if( indexOfString( "nonWSISSBPCompliance", oldPropNames ) != -1 ) + { + // We have an old SSBP value so we will use it's value as the default for settings. + String oldSSBPValue = oldPrefs.getString( "nonWSISSBPCompliance" ); + int oldSSBPIndex = indexOfString( oldSSBPValue, CONTEXT_IDS ); + String newSSBPValue = null; + + if( oldSSBPIndex < ENUM_ID_VALUES.length ) + { + newSSBPValue = ENUM_ID_VALUES[oldSSBPIndex]; + } + + if( newSSBPValue != null ) + { + ssbpState.putDefaultValue( "value", newSSBPValue ); + } + } + } + } + + private int indexOfString( String target, String[] values ) + { + int result = -1; + + for( int index = 0; index< values.length; index++ ) + { + String value = values[index]; + + if( value.equals( target ) ) + { + result = index; + break; + } + } + + return result; + } +} |