Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service')
-rw-r--r--bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/BaseOperationImpl.java233
-rw-r--r--bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/IConManager.java251
-rw-r--r--bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/PolicyOperationImpl.java121
-rw-r--r--bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/QuickFixActionInfoImpl.java59
-rw-r--r--bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/ScrolledPageContent.java66
-rw-r--r--bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/ServicePoliciesComposite.java1444
-rw-r--r--bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/ServicePolicyPlatformUIImpl.java194
-rw-r--r--bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/ServicePolicyRegistryUI.java288
-rw-r--r--bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/WstSPUIPluginMessages.java48
-rw-r--r--bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/WstSPUIPluginMessages.properties38
-rw-r--r--bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/preferences/ServicePoliciesPreferencePage.java136
-rw-r--r--bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/properties/ServicePoliciesPropertyPage.java311
-rw-r--r--bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/properties/ServicePolicyPropertyTester.java21
13 files changed, 0 insertions, 3210 deletions
diff --git a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/BaseOperationImpl.java b/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/BaseOperationImpl.java
deleted file mode 100644
index 6b90f8c4e..000000000
--- a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/BaseOperationImpl.java
+++ /dev/null
@@ -1,233 +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
- * -------- -------- -----------------------------------------------------------
- * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk, Initial coding of service policy
- *******************************************************************************/
-package org.eclipse.wst.ws.internal.service.policy.ui;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.wst.ws.service.policy.IDescriptor;
-import org.eclipse.wst.ws.service.policy.IServicePolicy;
-import org.eclipse.wst.ws.service.policy.IStateEnumerationItem;
-import org.eclipse.wst.ws.service.policy.ServicePolicyPlatform;
-import org.eclipse.wst.ws.service.policy.ui.IEnableOperation;
-import org.eclipse.wst.ws.service.policy.ui.ILaunchOperation;
-import org.eclipse.wst.ws.service.policy.ui.ServicePolicyActivatorUI;
-import org.eclipse.wst.ws.service.policy.ui.IPolicyOperation.OperationKind;
-import org.eclipse.wst.ws.service.policy.utils.RegistryUtils;
-
-public class BaseOperationImpl
-{
- private String id;
- private IDescriptor descriptor;
- private OperationKind operationKind;
- private String policyIdPattern;
- private boolean multiSelect = false;
- private ILaunchOperation launchOperationObject;
- private IEnableOperation enableOperationObject;
- private String enumId;
- private IConfigurationElement enabledElement;
- private IConfigurationElement complexElement;
- private boolean workspaceOnly;
- private String defaultItem;
- private boolean useDefaultData;
-
- public String getId()
- {
- return id;
- }
-
- public void setId(String id)
- {
- this.id = id;
- }
- public boolean isWorkspaceOnly()
- {
- return workspaceOnly;
- }
-
- public void setWorkspaceOnly( boolean workspaceOnly )
- {
- this.workspaceOnly = workspaceOnly;
- }
-
- public void setSelection( boolean isIcon )
- {
- if( isIcon )
- {
- operationKind = OperationKind.iconSelection;
- }
- else
- {
- operationKind = OperationKind.selection;
- }
- }
-
- public IDescriptor getDescriptor()
- {
- return descriptor;
- }
-
- public OperationKind getOperationKind()
- {
- return operationKind;
- }
-
- public String getEnumerationId()
- {
- return enumId;
- }
-
- public void setEnumerationId( String enumId )
- {
- this.enumId = enumId;
- operationKind = OperationKind.enumeration;
- }
-
- public String getPolicyIdPattern()
- {
- return policyIdPattern;
- }
-
- public boolean isEnabled( List<IServicePolicy> selectedPolicies )
- {
- boolean result = true;
-
- // If we don't allow multi select and multiple policies have been selected
- // then this operation is not enabled.
- if( !multiSelect && selectedPolicies.size() > 1 )
- {
- result = false;
- }
-
- if( result && enabledElement != null )
- {
- // We have an extension for this enablement code so we will call this
- // code.
- if( enableOperationObject == null )
- {
- try
- {
- String enabledClassName = RegistryUtils.getAttributeName( enabledElement, "enabledclass" ); //$NON-NLS-1$
- enableOperationObject = (IEnableOperation)enabledElement.createExecutableExtension( enabledClassName );
- }
- catch( Exception exc )
- {
- ServicePolicyActivatorUI.logError( "Error loading service policy ui \"enabled\" class.", exc ); //$NON-NLS-1$
- }
-
- if( enableOperationObject != null )
- {
- result = enableOperationObject.isEnabled( selectedPolicies );
- }
- }
- }
-
- return result;
- }
-
- public void launchOperation( IServicePolicy thisPolicy, List<IServicePolicy> selectedPolicies )
- {
- if( launchOperationObject == null )
- {
- try
- {
- String launchClassName = RegistryUtils.getAttributeName( complexElement, "launchclass" ); //$NON-NLS-1$
- launchOperationObject = (ILaunchOperation)complexElement.createExecutableExtension( launchClassName );
- }
- catch( Exception exc )
- {
- ServicePolicyActivatorUI.logError( "Error loading service policy ui launch class.", exc ); //$NON-NLS-1$
- }
- }
-
- if( launchOperationObject != null )
- {
- launchOperationObject.launch( selectedPolicies );
- }
- }
-
- public boolean isMultiSelect()
- {
- return multiSelect;
- }
-
- public void setMultiSelect(boolean multiSelect)
- {
- this.multiSelect = multiSelect;
- }
-
- public void setDescriptor(IDescriptor descriptor)
- {
- this.descriptor = descriptor;
- }
-
- public void setPolicyIdPattern(String policyIdPattern)
- {
- this.policyIdPattern = policyIdPattern;
- }
-
- public void setEnabledElement(IConfigurationElement enabledElement)
- {
- this.enabledElement = enabledElement;
- }
-
- public void setComplexElement(IConfigurationElement complexElement)
- {
- this.complexElement = complexElement;
- operationKind = OperationKind.complex;
- }
-
- public void setDefaultItem( String defaultItem )
- {
- this.defaultItem = defaultItem;
- }
-
- public String getDefaultItem()
- {
- if( defaultItem == null )
- {
- ServicePolicyPlatform platform = ServicePolicyPlatform.getInstance();
- List<IStateEnumerationItem> enumList = platform.getStateEnumeration( enumId );
-
- if( enumList != null )
- {
- defaultItem = enumList.get(0).getId();
-
- // No default item has been specified so we will search the enumeration for one.
- // If none was specified the first item in the enumeration is used.
- for( IStateEnumerationItem item : enumList )
- {
- if( item.isDefault() )
- {
- defaultItem = item.getId();
- break;
- }
- }
- }
- }
-
- return defaultItem;
- }
-
- public boolean isUseDefaultData()
- {
- return useDefaultData;
- }
-
- public void setUseDefaultData( boolean useDefaultData )
- {
- this.useDefaultData = useDefaultData;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/IConManager.java b/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/IConManager.java
deleted file mode 100644
index 3694962bb..000000000
--- a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/IConManager.java
+++ /dev/null
@@ -1,251 +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
- * -------- -------- -----------------------------------------------------------
- * 20071025 196997 pmoogk@ca.ibm.com - Peter Moogk, Initial coding.
- *******************************************************************************/
-package org.eclipse.wst.ws.internal.service.policy.ui;
-
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.resource.CompositeImageDescriptor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.wst.ws.service.policy.ui.ServicePolicyActivatorUI;
-import org.osgi.framework.Bundle;
-
-public class IConManager
-{
- private Map<String, Image> iconTable;
-
- public final String favorite = "fav"; //$NON-NLS-1$
- public final String invalid = "inv"; //$NON-NLS-1$
- public final String warning = "war"; //$NON-NLS-1$
- public final String lock = "loc"; //$NON-NLS-1$
-
- private String folderBaseURL;
- private String leafBaseURL;
- private Image favoriteImage;
- private Image invalidImage;
- private Image warningImage;
- private Image lockImage;
-
- private DecoratorDescriptor iconCreator;
-
- public IConManager()
- {
- iconTable = new HashMap<String, Image>();
- addOverlayIcons();
- iconCreator = new DecoratorDescriptor();
- }
-
- public String getFolderBaseUrl()
- {
- return folderBaseURL;
- }
-
- public String getLeafBaseUrl()
- {
- return leafBaseURL;
- }
-
- private void addOverlayIcons()
- {
- try
- {
- Bundle bundle = ServicePolicyActivatorUI.getDefault().getBundle();
- URL folderUrl = FileLocator.find( bundle, new Path( "icons/full/obj16/fldr_obj.gif" ), null ); //$NON-NLS-1$
- URL leafUrl = FileLocator.find( bundle, new Path( "icons/full/obj16/file_obj.gif" ), null ); //$NON-NLS-1$
- URL favoriteUrl = FileLocator.find( bundle, new Path( "icons/full/ovr16/favorite_ovr.gif" ), null ); //$NON-NLS-1$
- URL invalidUrl = FileLocator.find( bundle, new Path( "icons/full/ovr16/invalidtype_ovr.gif" ), null ); //$NON-NLS-1$
- URL warningUrl = FileLocator.find( bundle, new Path( "icons/full/ovr16/warning_ovr.gif" ), null ); //$NON-NLS-1$
- URL lockUrl = FileLocator.find( bundle, new Path( "icons/full/ovr16/unmodifiable_ovr.gif" ), null ); //$NON-NLS-1$
-
- getIconImage( folderUrl );
- getIconImage( leafUrl );
- favoriteImage = getIconImage( favoriteUrl );
- invalidImage = getIconImage( invalidUrl );
- warningImage = getIconImage( warningUrl );
- lockImage = getIconImage( lockUrl );
-
- folderBaseURL = folderUrl.toString();
- leafBaseURL = leafUrl.toString();
- }
- catch( Throwable exc )
- {
- ServicePolicyActivatorUI.logError( "Error reading icon overlays", exc ); //$NON-NLS-1$
- exc.printStackTrace();
- }
- }
-
- public boolean hasChanged( String[] string1, String[] string2 )
- {
- if( string1 == null || string2 == null || string1.length != string2.length ) return true;
-
- for( int index = 0; index < string1.length; index++ )
- {
- String value1 = string1[index];
- String value2 = string2[index];
-
- // We can do pointer comparison since we are using constant Strings.
- if( value1 != value2 )
- {
- return true;
- }
- }
-
- return false;
- }
-
- public Image getIconOverlay( String baseUrl, String[] overlays )
- {
- String imageUrl = getImageURL( baseUrl, overlays );
- Image result = (Image)iconTable.get( imageUrl );
-
- if( result == null )
- {
- Image baseImage = (Image)iconTable.get( baseUrl );
-
- if( baseImage == null )
- {
- // We need to load this baseImage
- try
- {
- baseImage = getIconImage( new URL( baseUrl ) );
- }
- catch( Exception exc )
- {
- ServicePolicyActivatorUI.logError( "Error loading image from:" + baseUrl, exc); //$NON-NLS-1$
- }
- }
-
- iconCreator.setBaseImage( baseImage, overlays );
-
- result = iconCreator.createImage();
- iconTable.put( imageUrl, result );
- }
-
- return result;
- }
-
- private boolean hasOverlay( String[] overlays, String value )
- {
- boolean result = false;
-
- for( String overlay : overlays )
- {
- // Note: We are using string pointer comparison here since, the strings
- // should only be the constants defined above.
- if( overlay == value )
- {
- result = true;
- break;
- }
- }
-
- return result;
- }
-
- private String getImageURL( String baseUrl, String[] overlays )
- {
- String url = baseUrl;
-
- for( String value : overlays )
- {
- if( value != null )
- {
- url = url + ":" + value; //$NON-NLS-1$
- }
- }
-
- return url;
- }
-
- public Image getIconImage( URL url )
- {
- String urlString = url.toString();
- Image image = iconTable.get( urlString );
-
- if( image == null )
- {
- ImageDescriptor imageDesc = ImageDescriptor.createFromURL(url);
-
- image = imageDesc.createImage();
- iconTable.put( urlString, image );
- }
-
- return image;
- }
-
- public void dispose()
- {
- for( Image image : iconTable.values() )
- {
- image.dispose();
- }
- }
-
- private class DecoratorDescriptor extends CompositeImageDescriptor
- {
- private Image baseImage;
- private Point size;
- private String[] overlays;
-
- protected void drawCompositeImage(int width, int height)
- {
- drawImage( baseImage.getImageData(), 0, 0);
-
- for( int index = 0; index < overlays.length; index++ )
- {
- if( hasOverlay(overlays, favorite) )
- {
- drawImage( favoriteImage.getImageData(), size.x - favoriteImage.getBounds().width, 0 );
- }
-
- if( hasOverlay( overlays, warning ) )
- {
- drawImage( warningImage.getImageData(), 0, size.y - warningImage.getBounds().height );
- }
-
- if( hasOverlay( overlays, invalid ) )
- {
- drawImage( invalidImage.getImageData(), 0, size.y - invalidImage.getBounds().height );
- }
-
- if( hasOverlay( overlays, lock ) )
- {
- drawImage( lockImage.getImageData(),
- size.x - lockImage.getBounds().width,
- size.y - lockImage.getBounds().height );
- }
- }
- }
-
- public void setBaseImage( Image image, String[] overlays )
- {
- Rectangle bounds = image.getBounds();
-
- this.baseImage = image;
- this.size = new Point( bounds.width, bounds.height );
- this.overlays = overlays;
- }
-
- protected Point getSize()
- {
- return size;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/PolicyOperationImpl.java b/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/PolicyOperationImpl.java
deleted file mode 100644
index 46e762e02..000000000
--- a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/PolicyOperationImpl.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2005 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.wst.ws.internal.service.policy.ui;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.wst.ws.service.policy.IDescriptor;
-import org.eclipse.wst.ws.service.policy.IPolicyState;
-import org.eclipse.wst.ws.service.policy.IServicePolicy;
-import org.eclipse.wst.ws.service.policy.ui.IPolicyOperation;
-
-public class PolicyOperationImpl implements IPolicyOperation
-{
- private BaseOperationImpl baseOperation;
- private IServicePolicy policy;
-
- public PolicyOperationImpl( BaseOperationImpl baseOperation, IServicePolicy policy )
- {
- this.baseOperation = baseOperation;
- this.policy = policy;
- }
-
- public String getDefaultItem()
- {
- return baseOperation.getDefaultItem();
- }
-
- public IDescriptor getDescriptor()
- {
- return baseOperation.getDescriptor();
- }
-
- public String getEnumerationId()
- {
- return baseOperation.getEnumerationId();
- }
-
- public String getId()
- {
- return baseOperation.getId();
- }
-
- public OperationKind getOperationKind()
- {
- return baseOperation.getOperationKind();
- }
-
- public String getPolicyIdPattern()
- {
- return baseOperation.getPolicyIdPattern();
- }
-
- public boolean isEnabled( List<IServicePolicy> selectedPolicies )
- {
- return baseOperation.isEnabled( selectedPolicies );
- }
-
- public boolean isWorkspaceOnly()
- {
- return baseOperation.isWorkspaceOnly();
- }
-
- public void launchOperation( List<IServicePolicy> selectedPolicies)
- {
- baseOperation.launchOperation( policy, selectedPolicies );
- }
-
- public IServicePolicy getServicePolicy()
- {
- return policy;
- }
-
- public String getStateItem( IProject project )
- {
- IPolicyState state = getState( project );
- String key = baseOperation.getId();
- String defaultItem = baseOperation.getDefaultItem();
-
- if( baseOperation.isUseDefaultData() )
- {
- key = IPolicyState.DefaultValueKey;
- }
-
- if( defaultItem != null )
- {
- state.putDefaultValue( key, defaultItem, false );
- }
-
- return state.getValue( key );
- }
-
- public void setStateItem( IProject project, String stateItem )
- {
- IPolicyState state = getState( project );
- String key = baseOperation.getId();
-
- if( baseOperation.isUseDefaultData() )
- {
- key = IPolicyState.DefaultValueKey;
- }
-
- state.putValue( key, stateItem );
- }
-
- private IPolicyState getState( IProject project )
- {
- return project == null ? policy.getPolicyState() : policy.getPolicyState( project );
- }
-
- public boolean isUseDefaultData()
- {
- return baseOperation.isUseDefaultData();
- }
-}
diff --git a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/QuickFixActionInfoImpl.java b/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/QuickFixActionInfoImpl.java
deleted file mode 100644
index e78ffb3f9..000000000
--- a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/QuickFixActionInfoImpl.java
+++ /dev/null
@@ -1,59 +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
- * -------- -------- -----------------------------------------------------------
- * 20071120 196997 pmoogk@ca.ibm.com - Peter Moogk, Initial coding.
- *******************************************************************************/
-package org.eclipse.wst.ws.internal.service.policy.ui;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.wst.ws.service.policy.IDescriptor;
-import org.eclipse.wst.ws.service.policy.ui.IQuickFixAction;
-import org.eclipse.wst.ws.service.policy.ui.IQuickFixActionInfo;
-import org.eclipse.wst.ws.service.policy.ui.ServicePolicyActivatorUI;
-
-public class QuickFixActionInfoImpl implements IQuickFixActionInfo
-{
- private IConfigurationElement element;
- private IDescriptor descriptor;
-
- public QuickFixActionInfoImpl( IConfigurationElement element, IDescriptor descriptor )
- {
- this.element = element;
- this.descriptor = descriptor;
- }
-
- public IQuickFixAction getAction()
- {
- IQuickFixAction result = null;
-
- try
- {
- Object action = element.createExecutableExtension( "class" ); //$NON-NLS-1$
-
- if( action instanceof IQuickFixAction )
- {
- result = (IQuickFixAction)action;
- }
- }
- catch( CoreException exc )
- {
- ServicePolicyActivatorUI.logError( "Error loading quick fix action.", exc ); //$NON-NLS-1$
- }
-
- return result;
- }
-
- public IDescriptor getDescriptor()
- {
- return descriptor;
- }
-}
diff --git a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/ScrolledPageContent.java b/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/ScrolledPageContent.java
deleted file mode 100644
index 2bbefc5cf..000000000
--- a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/ScrolledPageContent.java
+++ /dev/null
@@ -1,66 +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
- * -------- -------- -----------------------------------------------------------
- * 20071120 209858 ericdp@ca.ibm.com - Eric Peters, Enhancing service policy framework and UI
- *******************************************************************************/
-package org.eclipse.wst.ws.internal.service.policy.ui;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.forms.FormColors;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.SharedScrolledComposite;
-
-
-public class ScrolledPageContent extends SharedScrolledComposite {
-
- private FormToolkit fToolkit;
-
- public ScrolledPageContent(Composite parent) {
- this(parent, SWT.V_SCROLL | SWT.H_SCROLL);
- }
-
- public ScrolledPageContent(Composite parent, int style) {
- super(parent, style);
-
- setFont(parent.getFont());
-
- fToolkit= getDialogsFormToolkit();
-
- setExpandHorizontal(true);
- setExpandVertical(true);
-
- Composite body= new Composite(this, SWT.NONE);
- body.setFont(parent.getFont());
- setContent(body);
- }
-
- public FormToolkit getDialogsFormToolkit() {
- if (fToolkit == null) {
- FormColors colors= new FormColors(Display.getCurrent());
- colors.setBackground(null);
- colors.setForeground(null);
- fToolkit= new FormToolkit(colors);
- }
- return fToolkit;
- }
-
- public void adaptChild(Control childControl) {
- fToolkit.adapt(childControl, true, true);
- }
-
- public Composite getBody() {
- return (Composite) getContent();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/ServicePoliciesComposite.java b/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/ServicePoliciesComposite.java
deleted file mode 100644
index 069d96aaf..000000000
--- a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/ServicePoliciesComposite.java
+++ /dev/null
@@ -1,1444 +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
- * -------- -------- -----------------------------------------------------------
- * 20071106 196997 ericdp@ca.ibm.com - Eric Peters
- * 20071120 209858 ericdp@ca.ibm.com - Eric Peters, Enhancing service policy framework and UI
- * 20071212 209858 ericdp@ca.ibm.com - Eric Peters, Enhancing service policy framework and UI
- *******************************************************************************/
-package org.eclipse.wst.ws.internal.service.policy.ui;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.forms.events.ExpansionAdapter;
-import org.eclipse.ui.forms.events.ExpansionEvent;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.help.IWorkbenchHelpSystem;
-import org.eclipse.wst.ws.service.policy.IDescriptor;
-import org.eclipse.wst.ws.service.policy.IPolicyEnumerationList;
-import org.eclipse.wst.ws.service.policy.IPolicyRelationship;
-import org.eclipse.wst.ws.service.policy.IPolicyState;
-import org.eclipse.wst.ws.service.policy.IPolicyStateEnum;
-import org.eclipse.wst.ws.service.policy.IServicePolicy;
-import org.eclipse.wst.ws.service.policy.IStateEnumerationItem;
-import org.eclipse.wst.ws.service.policy.ServicePolicyPlatform;
-import org.eclipse.wst.ws.service.policy.listeners.IPolicyChildChangeListener;
-import org.eclipse.wst.ws.service.policy.ui.IPolicyOperation;
-import org.eclipse.wst.ws.service.policy.ui.ServicePolicyActivatorUI;
-import org.eclipse.wst.ws.service.policy.ui.ServicePolicyPlatformUI;
-import org.eclipse.wst.ws.service.policy.ui.IPolicyOperation.OperationKind;
-import org.osgi.framework.Bundle;
-
-public class ServicePoliciesComposite extends Composite implements
- SelectionListener, IPolicyChildChangeListener {
-
- private ScrolledComposite operationsScrolledComposite;
- //a scrollable composite containing operations available for the selected policies
- private Composite operationsComposite;
- private IWorkbenchHelpSystem helpSystem;
- private Composite masterComposite;
- private Composite detailsComposite;
- private Tree masterPolicyTree;
- //tertiary and higher level policy nodes in a separate tree
- private Tree detailsPolicyTree;
- private Text text_DetailsPanel_description;
- private Text text_DetailsPanel_dependencies;
- private Label label_DetailsPanel_description;
- private Label label_detailsPanel_dependancies;
- private Hashtable<String, IStatus> allErrors;
- private IStatus error;
- private boolean bComplexOpCompleted = true;
- private List<ChildChangeEvent> listChildChangeEvents;
- private IConManager iconManager = new IConManager();
- private IProject project = null;
- private SelectionListener listener;
- private ExpandableComposite excomposite;
- private ServicePolicyPlatform platform = ServicePolicyPlatform
- .getInstance();
- private ServicePolicyPlatformUI platformUI = ServicePolicyPlatformUI
- .getInstance();;
-
- /**
- * Creates an expandable composite
- * @param parent
- * @param nColumns
- * @return
- */
- private ExpandableComposite createExpandableComposite(Composite parent,
- int nColumns) {
- ExpandableComposite excomposite = new ExpandableComposite(parent,
- SWT.NONE, ExpandableComposite.TWISTIE
- | ExpandableComposite.CLIENT_INDENT);
- excomposite.setExpanded(false);
- excomposite.setVisible(false);
- excomposite.setFont(JFaceResources.getFontRegistry().getBold(
- JFaceResources.DIALOG_FONT));
- excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
- true, false, nColumns, 1));
- excomposite.addExpansionListener(new ExpansionAdapter() {
- public void expansionStateChanged(ExpansionEvent e) {
- expandedStateChanged((ExpandableComposite) e.getSource());
- }
- });
- makeScrollableCompositeAware(excomposite);
- return excomposite;
- }
-
- /**
- * @author ericdp
- * Helper class that encapsulates data required when an action control changes state
- *
- */
- private class ActionControlData {
- private List<IServicePolicy> spList;
- private List<IPolicyOperation> poList;
-// private IPolicyOperation po;
-
- public ActionControlData(List<IServicePolicy> spList, List<IPolicyOperation> poList) {
- this.spList = spList;
- this.poList = poList;
- }
- public List<IServicePolicy> getSpList() {
- return spList;
- }
-
- public void setSpList(List<IServicePolicy> spList) {
- this.spList = spList;
- }
-//
-// public IPolicyOperation getPo() {
-// return po;
-// }
-//
-// public void setPo(IPolicyOperation po) {
-// this.po = po;
-// }
-
- public List<IPolicyOperation> getPoList() {
- return poList;
- }
-
- public void setPoList(List<IPolicyOperation> poList) {
- this.poList = poList;
- }
- }
-
- /**
- * Makes the scrollable composite aware of this control, so expand/collapse
- * of the scrollable composite will move this control down/up accordingly
- * @param control the control to make the scrollable composite aware of
- */
- private void makeScrollableCompositeAware(Control control) {
- ScrolledPageContent parentScrolledComposite = getParentScrolledComposite(control);
- if (parentScrolledComposite != null) {
- parentScrolledComposite.adaptChild(control);
- }
- }
-
- private ScrolledPageContent getParentScrolledComposite(Control control) {
- Control parent = control.getParent();
- while (!(parent instanceof ScrolledPageContent) && parent != null) {
- parent = parent.getParent();
- }
- if (parent instanceof ScrolledPageContent) {
- return (ScrolledPageContent) parent;
- }
- return null;
- }
-
- private final void expandedStateChanged(ExpandableComposite expandable) {
- ScrolledPageContent parentScrolledComposite = getParentScrolledComposite(expandable);
- if (parentScrolledComposite != null) {
- parentScrolledComposite.reflow(true);
- }
- }
-
- /**
- * @param parent
- * @return a scrollable composite containing an expandable content
- *
- */
- private Composite createDetailsScrollPageContent(Composite parent) {
-
- int nColumns = 1;
-
- final ScrolledPageContent pageContent = new ScrolledPageContent(parent);
-
- GridLayout pageContLayout = new GridLayout();
- pageContLayout.numColumns = nColumns;
- pageContLayout.marginHeight = 0;
- pageContLayout.marginWidth = 0;
-
- Composite composite = pageContent.getBody();
- composite.setLayout(pageContLayout);
-
- excomposite = createExpandableComposite(composite, nColumns);
-
- Composite inner = new Composite(excomposite, SWT.NONE);
- inner.setFont(composite.getFont());
- inner.setLayout(new GridLayout(nColumns, false));
- excomposite.setClient(inner);
- //details policy tree for tertiary and higher level service policies
- detailsPolicyTree = new Tree(inner, SWT.BORDER | SWT.MULTI);
- detailsPolicyTree.addSelectionListener(this);
- GridData detailsPrefTreeGD = new GridData(
- GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
- detailsPrefTreeGD.heightHint = 50;
- detailsPolicyTree.setLayoutData(detailsPrefTreeGD);
- detailsPolicyTree.setToolTipText(WstSPUIPluginMessages.TOOLTIP_PSP_DETAILSTREE);
- //make the scrollable composite aware of the tree so expand/collapse works properly
- makeScrollableCompositeAware(detailsPolicyTree);
-
- createPolicyOperationsComposite(composite);
-
- label_DetailsPanel_description = new Label(composite, SWT.NONE);
-
- label_DetailsPanel_description
- .setText(WstSPUIPluginMessages.LABEL_SERVICEPOLICIES_DESCRIPTION);
- makeScrollableCompositeAware(label_DetailsPanel_description);
- text_DetailsPanel_description = new Text(composite, SWT.WRAP
- | SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
- GridData detailsGD = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.GRAB_HORIZONTAL);
- detailsGD.heightHint = 50;
- detailsGD.widthHint = 400;
- text_DetailsPanel_description.setLayoutData(detailsGD);
- text_DetailsPanel_description.setToolTipText(WstSPUIPluginMessages.TOOLTIP_PSP_DESCRIPTION);
-
- makeScrollableCompositeAware(text_DetailsPanel_description);
- label_detailsPanel_dependancies = new Label(composite, SWT.NONE);
- makeScrollableCompositeAware(label_detailsPanel_dependancies);
- label_detailsPanel_dependancies
- .setText(WstSPUIPluginMessages.LABEL_SERVICEPOLICIES_DEPENDENCIES);
- text_DetailsPanel_dependencies = new Text(composite, SWT.WRAP
- | SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
- text_DetailsPanel_dependencies.setToolTipText(WstSPUIPluginMessages.TOOLTIP_PSP_DEPENDENCIES);
- makeScrollableCompositeAware(text_DetailsPanel_dependencies);
- GridData dependenciesGD = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.GRAB_HORIZONTAL);
- dependenciesGD.heightHint = 100;
- dependenciesGD.widthHint = 400;
- text_DetailsPanel_dependencies.setLayoutData(dependenciesGD);
-
- return pageContent;
- }
-
- /**
- * Creates the scrollable composite that will contain widgets associated with a policy operation
- * @param parent the parent composite
- */
- private void createPolicyOperationsComposite(Composite parent) {
- operationsScrolledComposite = new ScrolledComposite(parent,
- SWT.H_SCROLL | SWT.V_SCROLL);
- operationsScrolledComposite.setExpandHorizontal(true);
- operationsScrolledComposite.setExpandVertical(true);
- GridData operationsScrolledCompositeGD = new GridData(
- GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
- operationsScrolledCompositeGD.heightHint =60;
- operationsScrolledComposite.setLayoutData(operationsScrolledCompositeGD);
- operationsComposite = new Composite(operationsScrolledComposite,
- SWT.NONE);
- operationsScrolledComposite.setContent(operationsComposite);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- operationsComposite.setLayout(layout);
-// GridData operationsCompositeGD = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
-// operationsCompositeGD.heightHint = 1000;
-// operationsCompositeGD.widthHint = 1000;
-// operationsComposite.setLayoutData(operationsCompositeGD);
- operationsScrolledComposite.setMinSize(operationsComposite.computeSize(
- 400, 100));
- makeScrollableCompositeAware(operationsScrolledComposite);
- makeScrollableCompositeAware(operationsComposite);
- }
-
- public ServicePoliciesComposite(Composite parent, IProject project,
- SelectionListener listener) {
-
- super(parent, SWT.NONE);
- this.project = project;
- this.listener = listener;
- allErrors = new Hashtable<String, IStatus>();
- helpSystem = PlatformUI.getWorkbench().getHelpSystem();
- GridLayout parentLayout = new GridLayout();
- parentLayout.numColumns = 2;
- parentLayout.horizontalSpacing = 0;
- this.setLayout(parentLayout);
- this.setLayoutData(new GridData(GridData.FILL_BOTH));
- masterComposite = new Composite(this, SWT.NONE);
-
- GridLayout masterLayout = new GridLayout();
- masterLayout.numColumns = 1;
- masterLayout.horizontalSpacing = 0;
- masterComposite.setLayout(masterLayout);
- masterComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
-
- detailsComposite = new Composite(this, SWT.NONE);
- GridLayout detailsLayout = new GridLayout();
- detailsLayout.numColumns = 1;
- detailsLayout.horizontalSpacing = 0;
- detailsComposite.setLayout(detailsLayout);
- detailsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
- masterPolicyTree = new Tree(masterComposite, SWT.BORDER | SWT.MULTI);
- masterPolicyTree.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- masterPolicyTree.setToolTipText(WstSPUIPluginMessages.TOOLTIP_PSP_TREE);
-
- Composite othersComposite = createDetailsScrollPageContent(detailsComposite);
- GridData gridData = new GridData(GridData.FILL, GridData.FILL, true,
- true);
- othersComposite.setLayoutData(gridData);
-
- masterPolicyTree.addSelectionListener(this);
-
- List<IServicePolicy> policyList = platform.getRootServicePolicies(null);
-
- for (IServicePolicy policy : policyList) {
- addPolicy(policy, masterPolicyTree, true);
- }
- TreeItem[] treeItems = masterPolicyTree.getItems();
- if (treeItems.length > 0) {
- //select the first item in the tree & fire event so UI is updated
- masterPolicyTree.setSelection(treeItems[0]);
- masterPolicyTree.notifyListeners(SWT.Selection, new Event());
- }
-
-
-
- }
-
- /**
- * Sets the image on ti, if associated service policy defines an icon
- * it will will be used, otherwise default Folder/Leaf icons will be used
- * @param ti the TreeItem to set the image for
- * @param sp the service policy associated with ti
- * @param iconOverlays description of which overlays should be applied
- */
- private void setImage(TreeItem ti, IServicePolicy sp, String[] iconOverlays) {
- Image i = (sp.getChildren().size() == 0) ? iconManager.getIconOverlay(
- iconManager.getLeafBaseUrl(), iconOverlays) : iconManager
- .getIconOverlay(iconManager.getFolderBaseUrl(), iconOverlays);
- if (sp.getDescriptor() != null) {
- String iconPathBundleID = null;
- String iconPath = null;
- iconPathBundleID = sp.getDescriptor().getIconBundleId();
- iconPath = sp.getDescriptor().getIconPath();
- if (iconPathBundleID != null && iconPath != null
- && iconPathBundleID.length() > 0 && iconPath.length() > 0) {
- Bundle b = Platform.getBundle(iconPathBundleID);
- i = iconManager.getIconOverlay(FileLocator.find(b,
- new Path(iconPath), null).toString(), iconOverlays);
- }
- }
- ti.setImage(i);
- // image has changed, notify change listeners so tree gets updated
- ti.notifyListeners(SWT.Modify, new Event());
- }
-
- private boolean is3rdLevelOrHigherPolicy (IServicePolicy sp) {
- return sp.getParentPolicy() != null
- && sp.getParentPolicy().getParentPolicy() != null;
-
- }
- /**
- * Add service policy sp and children of sp to the parent
- * @param sp the service policy to add
- * @param parent either a Tree (masterPolicyTree or DetailsPolicyTree), or a TreeItem
- * to add service policy children to
- * @param addUpToLevel2Only false if should add tertiary and higher level
- * child policies
- */
- private void addPolicy(IServicePolicy sp, Widget parent,
- boolean addUpToLevel2Only) {
- sp.addPolicyChildChangeListener(this);
- if (addUpToLevel2Only && is3rdLevelOrHigherPolicy(sp) )
- // don't add tertiary and higher branches, these are added on demand
- // to a different tree
- return;
- TreeItem ti;
- if (parent instanceof TreeItem)
- ti = new TreeItem((TreeItem) parent, SWT.NONE);
- else
- ti = new TreeItem((Tree) parent, SWT.NONE);
- ti.setText(sp.getDescriptor().getLongName());
- ti.setData(sp);
-
- setImage(ti, sp, getIconOverlayInfo(sp, false));
- List<IServicePolicy> childrenPolicyList = sp.getChildren();
- for (IServicePolicy policy : childrenPolicyList) {
- addPolicy(policy, ti, addUpToLevel2Only);
- }
-
- }
-
- /**
- * Returns icon overlay information
- * @param sp the service policy that should have some overlay images associated with it
- * @param invalid true if the service policy is valid
- * @return String[] containing information about what overlays to apply to the icon that
- * is associated with sp
- */
- private String[] getIconOverlayInfo(IServicePolicy sp, boolean invalid) {
- String[] overLays = new String[4];
-
- IPolicyState polState = (project == null) ? sp.getPolicyState() : sp
- .getPolicyState(project);
- IPolicyStateEnum polEnum = (project == null) ? sp.getPolicyStateEnum()
- : sp.getPolicyStateEnum(project);
- if (!polState.isMutable())
- overLays[0] = iconManager.lock;
- if ((sp.getStatus() != null && sp.getStatus().getSeverity() == IStatus.ERROR) || invalid)
- overLays[1] = iconManager.invalid;
- if ((sp.getStatus() != null && sp.getStatus().getSeverity() == IStatus.WARNING))
- overLays[2] = iconManager.warning;
- if (polEnum != null) {
- if (polEnum.getEnumId().equals(
- "org.eclipse.wst.service.policy.booleanEnum")) { //$NON-NLS-1$
- if (policyHasIconSelectionOperationSelected(sp))
- overLays[3] = iconManager.favorite;
- }
-
- }
- return overLays;
- }
-
- /**
- * @param sp
- */
- private boolean policyHasIconSelectionOperationSelected(IServicePolicy sp) {
- boolean iconSelectionOperationSelected = false;
- List<IPolicyOperation> operationList = platformUI.getOperations(sp, project == null);
- for (IPolicyOperation operationItem : operationList) {
- if (operationItem.getOperationKind().equals(OperationKind.iconSelection)) {
- String stateID = operationItem.getStateItem(project);
- if (stateID.equals("org.eclipse.wst.true")) //$NON-NLS-1$
- return true;
- }
-
- }
- return iconSelectionOperationSelected;
- }
-
- /**
- * Does anything necessary because the default button has been pressed.
- */
- public void performDefaults() {
- initializeDefaults();
- TreeItem selected = null;
- IServicePolicy focusSP = null;
- // fire selection event to tree that is associated with operation UI so
- // operation UI gets updated
- if (detailsPolicyTree.isVisible()
- && detailsPolicyTree.getSelection().length > 0) {
- detailsPolicyTree.notifyListeners(SWT.Selection, new Event());
- selected = detailsPolicyTree.getSelection()[0];
- focusSP = (IServicePolicy) selected.getData();
- } else if (masterPolicyTree.getSelection().length > 0) {
- masterPolicyTree.notifyListeners(SWT.Selection, new Event());
- selected = masterPolicyTree.getSelection()[0];
- focusSP = (IServicePolicy) selected.getData();
- }
-
- error = validateAllPolicies(focusSP);
-
- }
- private class ChildChangeEvent {
- public ChildChangeEvent(List<IServicePolicy> changedChildren, List<Boolean> added ) {
- this.changedChildren = changedChildren;
- this.added = added;
-
- }
- private List<IServicePolicy> changedChildren;
- private List<Boolean> added;
- public List<IServicePolicy> getChangedChildren() {
- return changedChildren;
- }
- public void setChangedChildren(List<IServicePolicy> changedChildren) {
- this.changedChildren = changedChildren;
- }
- public List<Boolean> getAdded() {
- return added;
- }
- public void setAdded(List<Boolean> added) {
- this.added = added;
- }
- }
- /* (non-Javadoc)
- * @see org.eclipse.wst.ws.service.policy.listeners.IPolicyChildChangeListener#childChange(List<org.eclipse.wst.ws.service.policy.IServicePolicy>, List<java.lang.Boolean>)
- */
- public void childChange( List<IServicePolicy> child, List<Boolean> added ) {
- //ignore events unless we are in a complex operation
- if (!bComplexOpCompleted)
- //cache the event until complex operation completed
- listChildChangeEvents.add(new ChildChangeEvent(child, added));
-
- }
-
-
- /**
- * @param child
- * @param added
- */
- private void processChildChangeEvent(ChildChangeEvent cce,
- Hashtable<String, IServicePolicy> htTopLevelAddtions) {
- List<IServicePolicy> changedServicePolicyList = cce.getChangedChildren();
- List<Boolean> changedServicePolicyAddedList = cce.getAdded();
- for (int i = 0; i < changedServicePolicyList.size(); i++) {
- IServicePolicy nextChangedServicePolicy = changedServicePolicyList.get(i);
- boolean added = changedServicePolicyAddedList.get(i);
- if (!added) {
- //delete node
- processChildChangeEventRemoveServicePolicy(nextChangedServicePolicy);
- } else {
- //an addition, only process top level additions as this is a recursive operation (adds children too)
- if (htTopLevelAddtions.containsKey(nextChangedServicePolicy.getId())) {
- processChildChangeEventAddServicePolicy(nextChangedServicePolicy);
- }
- }
- }
- }
-
-
- /**
- * @param nextChangedServicePolicy
- */
- private void processChildChangeEventRemoveServicePolicy(IServicePolicy nextChangedServicePolicy) {
- boolean is3rdLevelOrHigher = is3rdLevelOrHigherPolicy(nextChangedServicePolicy);
- if (is3rdLevelOrHigher) {
- if (detailsPolicyTree.isVisible()) {
- TreeItem[] children = detailsPolicyTree.getItems();
- TreeItem found = null;
- for (int i=0; i < children.length; i++) {
- found = findPolicy(nextChangedServicePolicy, children[i]);
- if (found != null)
- break;
- }
- if (found != null && !found.isDisposed()) {
- processChildChangeEventDeleteTreeItem(found);
- }
- }
- } else {
- TreeItem[] children = masterPolicyTree.getItems();
- TreeItem found = null;
- for (int i=0; i < children.length; i++) {
- found = findPolicy(nextChangedServicePolicy, children[i]);
- if (found != null)
- break;
- }
- if (found != null && !found.isDisposed()) {
- processChildChangeEventDeleteTreeItem(found);
-
- }
-
-
-
- }
-
- }
-
- /**
- * Delete the item, and choose set a new selection as appropriate from one of the policy trees
- * @param deleteItem
- */
- private void processChildChangeEventDeleteTreeItem(TreeItem deleteItem) {
- Tree parentTree = deleteItem.getParent();
- Tree selectionTree = parentTree;
- TreeItem parentTreeItem = deleteItem.getParentItem();
- //index of found in the tree
- int idx = (parentTreeItem == null) ? parentTree.indexOf(deleteItem) : parentTreeItem.indexOf(deleteItem);
- //is index the last index in the tree
- boolean isLastIndex = (parentTreeItem == null) ? parentTree.indexOf(deleteItem) == parentTree.getItemCount() -1 : parentTreeItem.indexOf(deleteItem) == parentTreeItem.getItemCount() -1;
- //number of siblings
- int siblingsCount = (parentTreeItem == null) ? parentTree.getItemCount() -1 : parentTreeItem.getItemCount() -1;
- boolean hasParent = (parentTreeItem == null) ? parentTree.getItemCount() == 0 : parentTreeItem.getItemCount() == 0;
- deleteItem.dispose();
- if (parentTreeItem == null)
- parentTree.redraw();
- else
- parentTree.redraw();
- TreeItem selectItem = null;
- if (siblingsCount == 0) {
- if (hasParent) {
- //no siblings, select parent
- if (parentTreeItem == null)
- selectItem = parentTree.getItem(0);
- else
- selectItem = parentTreeItem;
- } else {
- if (parentTree == detailsPolicyTree)
- //select something from master tree
- if (masterPolicyTree.getItems().length > 0) {
- selectItem = masterPolicyTree.getItem(0);
- selectionTree = masterPolicyTree;
- }
-
- }
-
- } else {
- if (parentTreeItem == null) {
- if (isLastIndex)
- selectItem = parentTree.getItem(idx -1);
- else
- selectItem = parentTree.getItem(idx);
- } else {
- if (isLastIndex)
- selectItem = parentTreeItem.getItem(idx -1);
- else
- selectItem = parentTreeItem.getItem(idx);
-
- }
- }
- if (selectItem != null) {
- selectionTree.setSelection(selectItem);
- selectionTree.notifyListeners(SWT.Selection, new Event());
- }
- }
-
- /**
- * @param policyToAdd
- */
- private void processChildChangeEventAddServicePolicy(IServicePolicy policyToAdd) {
- boolean is3rdLevelOrHigher = is3rdLevelOrHigherPolicy(policyToAdd);
- IServicePolicy parent = policyToAdd.getParentPolicy();
- if (is3rdLevelOrHigher) {
- if (detailsPolicyTree.isVisible()) {
- TreeItem[] children = detailsPolicyTree.getItems();
- TreeItem found = null;
- for (int i=0; i < children.length; i++) {
- found = findPolicy(parent, children[i]);
- if (found != null)
- break;
- }
- if (found != null && !found.isDisposed()) {
- addPolicy(policyToAdd, found, false);
- }
- }
- } else {
- //less than 3rd level policy
- TreeItem[] children = masterPolicyTree.getItems();
- TreeItem found = null;
- for (int i=0; i < children.length; i++) {
- found = findPolicy(parent, children[i]);
- if (found != null)
- break;
- }
- if (found != null && !found.isDisposed()) {
- addPolicy(policyToAdd, found, false);
-
- }
- }
- }
-
- /**
- * Find the policy within the tree ti
- * @param policyToFind
- */
- private TreeItem findPolicy(IServicePolicy policyToFind, TreeItem ti) {
- TreeItem toReturn = null;
- if (ti == null || !(ti.getData() instanceof IServicePolicy))
- return toReturn;
- IServicePolicy sp = (IServicePolicy)ti.getData();
- if (sp.getId().equals(policyToFind.getId()))
- return ti;
- else {
- TreeItem[] tiChildren = ti.getItems();
- for (int i =0; i < tiChildren.length; i++) {
- toReturn = findPolicy(policyToFind, tiChildren[i]);
- if (toReturn != null)
- break;
- }
- }
- return toReturn;
- }
- /**
- * Initializes states of the controls using default values in the preference
- * store.
- */
- private void initializeDefaults() {
- if (project == null)
- platform.restoreDefaults();
- else
- platform.restoreDefaults(project);
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- if (e.getSource() == masterPolicyTree || e.getSource() == detailsPolicyTree) {
- TreeItem[] selectedItems;
- if (e.getSource() == masterPolicyTree)
- selectedItems = masterPolicyTree.getSelection();
- else
- selectedItems = detailsPolicyTree.getSelection();
- //possible that an event is fired and no nodes selected
- if (!(selectedItems.length > 0))
- return;
- List<IServicePolicy> sp = new Vector<IServicePolicy>();
- for (int i = 0; i < selectedItems.length; i++) {
- sp.add((IServicePolicy) selectedItems[i].getData());
- }
- //update the context sensitive help
- updateCSH(sp);
- updateInfoPanels(sp);
-
- if (e.getSource() == masterPolicyTree) {
- // if selected node in master tree is 2nd level & has
- // children, populate details tree
- if (sp.get(0).getParentPolicy() != null
- && sp.get(0).getChildren().size() > 0) {
- populateDetailsPolicyTree(sp);
- } else {
- //if expandable composite was visible, collapse and set invisible
- if (excomposite.getVisible()) {
- excomposite.setVisible(false);
- excomposite.setExpanded(false);
- expandedStateChanged(excomposite);
- }
- }
- }
- addActionButtons(sp);
-
- } else {
- // an action control fired a change event
- Control actionControl = (Control) e.getSource();
- updatePolicy(actionControl);
- //policy updates might delete nodes in the tree, so make sure action control not disposed
- IServicePolicy changedSP = null;
- if (!actionControl.isDisposed())
- changedSP = ((ActionControlData) actionControl.getData())
- .getSpList().get(0);
- error = validateAllPolicies(changedSP);
- //inform listeners that a control has changed, as composite may be in error now
- listener.widgetSelected(e);
-
- }
-
- }
-
- /**
- * Populate the details policy tree with sp and their children
- * @param sp a list of top level details tree service policies
- */
- private void populateDetailsPolicyTree(List<IServicePolicy> sp) {
- List<IServicePolicy> childpolicyList = sp.get(0)
- .getChildren();
- detailsPolicyTree.removeAll();
- for (IServicePolicy policy : childpolicyList) {
- addPolicy(policy, detailsPolicyTree, false);
- }
- // update details preference tree
- TreeItem[] treeItems = detailsPolicyTree.getItems();
- for (int i = 0; i < treeItems.length; i++) {
- updateValidStates(treeItems[i], true);
- }
-
- excomposite.setVisible(true);
- excomposite.setText(sp.get(0).getDescriptor().getLongName()
- + " (" + WstSPUIPluginMessages.TEXT_DETAILS + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- // text has changed, so need to force layout so updated
- excomposite.layout();
- }
-
- /**
- * Updates the details and dependencies panels for the first service
- * policy in spList
- * @param spList a list of selected service policies
- */
- private void updateInfoPanels(List<IServicePolicy> spList) {
- String desc = (spList.get(0) == null
- || spList.get(0).getDescriptor() == null || spList.get(0)
- .getDescriptor().getDescription() == null) ? "" : spList.get(0) //$NON-NLS-1$
- .getDescriptor().getDescription();
- text_DetailsPanel_description.setText(desc);
- text_DetailsPanel_dependencies.setText(getDependanciesText(spList
- .get(0)));
- }
-
- /**
- * Updates the context sensitive help for the composite with
- * that defined for the first policy in spList (or a parent of
- * first policy in spList policy does not define any CSH)
- * @param spList the list of selected service policies
- */
- private void updateCSH(List<IServicePolicy> spList) {
- String CSH_ID = (spList.get(0) == null || spList.get(0).getDescriptor() == null) ? null
- : spList.get(0).getDescriptor().getContextHelpId();
- IServicePolicy parentSP = spList.get(0);
- while ((CSH_ID == null || CSH_ID.length() == 0)) {
- parentSP = parentSP.getParentPolicy();
- if (parentSP == null)
- break;
- CSH_ID = (parentSP.getDescriptor() == null) ? null : parentSP
- .getDescriptor().getContextHelpId();
- }
- helpSystem.setHelp(this, CSH_ID);
- }
-
- /**
- * Validates all Service Policies in the model
- *
- * @param IServicePolicy
- * the focus policy, i.e. one that changed state
- * @return IStatus null if no Service policies in error, otherwise a Service
- * Policy error (the focucPolicy error if it is in error).
- * Postcondition- the error property is updated.
- */
- private IStatus validateAllPolicies(IServicePolicy focusPolicy) {
- // remove all errors as going to re-validate
- allErrors.clear();
- // re-validate all policies in model
- List<IServicePolicy> servicePolicyList = platform
- .getRootServicePolicies(null);
- for (IServicePolicy servicePolicyItem : servicePolicyList) {
- validatePolicy(servicePolicyItem);
- }
- // define error message
- IStatus error = (focusPolicy == null) ? null : allErrors
- .get(focusPolicy.getId());
- if (error == null)
- if (!allErrors.isEmpty())
- error = allErrors.get(allErrors.keys().nextElement());
-
- // update master policy tree
- TreeItem[] treeItems = masterPolicyTree.getItems();
- for (int i = 0; i < treeItems.length; i++) {
- updateValidStates(treeItems[i], false);
- }
- if (detailsPolicyTree.isVisible()) {
- // update details preference tree
- treeItems = detailsPolicyTree.getItems();
- for (int i = 0; i < treeItems.length; i++) {
- updateValidStates(treeItems[i], false);
- }
-
- }
- return error;
- }
-
- /**
- * Updates the policy trees to reflect valid or invalid states, invalid states are
- * propagated up through the tree, and up to master tree if updateDetailsOnly is false
- * @param ti the TreeItem to update, updates ti and all it's children
- * @param updateDetailsOnly if false then propagate invalid states into
- * master tree
- */
- private void updateValidStates(TreeItem ti, boolean updateDetailsOnly) {
- // assume tree item is valid for now
- IServicePolicy sp = (IServicePolicy) ti.getData();
- setValidPolicyState(ti);
-
- if (allErrors.containsKey(sp.getId()))
- setInvalidPolicyState(ti, updateDetailsOnly);
- TreeItem[] treeItems = ti.getItems();
- if (ti.getItems().length == 0) {
- if (sp.getChildren().size() != 0 && policyChildrenInvalid(sp))
- setInvalidPolicyState(ti, updateDetailsOnly);
- } else {
- for (int i = 0; i < treeItems.length; i++) {
-
- updateValidStates(treeItems[i], updateDetailsOnly);
- }
- }
-
- }
-
- /**
- * Checks whether the sp has invalid children
- * @param sp the service policy whose children may be invalid
- * @return true if sp has an invalid child
- */
- private boolean policyChildrenInvalid(IServicePolicy sp) {
- boolean toReturn = false;
- List<IServicePolicy> servicePolicyList = sp.getChildren();
- for (IServicePolicy servicePolicyItem : servicePolicyList) {
- if (allErrors.containsKey(servicePolicyItem.getId()))
- return true;
- else
- toReturn = policyChildrenInvalid(servicePolicyItem);
- }
- return toReturn;
- }
-
- /**
- * Validates the Service Policies for the sp and all it's children, creating
- * error status objects for any unsatisfied relationships
- *
- * @param sp
- * the service policy to validate
- */
- private void validatePolicy(IServicePolicy sp) {
- String operationLongName;
- String operationSelectionLongName;
- String dependantPolicyShortName;
- List<IPolicyRelationship> relationShipList = sp.getRelationships();
- String currentValueID = null;
- if (relationShipList != null && relationShipList.size() > 0) {
- for (IPolicyRelationship relationShipItem : relationShipList) {
- //operations for the policy
- List<IPolicyOperation> policyOperationsList = platformUI
- .getOperations(relationShipItem.getPolicyEnumerationList()
- .getPolicy(), project == null);
- //default operation name
- operationLongName = ""; //$NON-NLS-1$
- for (IPolicyOperation policyOperationItem : policyOperationsList) {
- if (policyOperationItem.isUseDefaultData()) {
- operationLongName = policyOperationItem.getDescriptor()
- .getLongName();
- currentValueID = policyOperationItem.getStateItem(project);
- break;
- }
- }
- // a list of states
- List<IStateEnumerationItem> spStateEnumerationList = relationShipItem
- .getPolicyEnumerationList().getEnumerationList();
- // a list of related policies and their acceptable states to satisfy a stateEnumerationItem in spStateEnumerationList
- List<IPolicyEnumerationList> relatedPolicies = relationShipItem
- .getRelatedPolicies();
- for (IStateEnumerationItem stateEnumerationItem : spStateEnumerationList) {
- if (stateEnumerationItem.getId() != currentValueID)
- continue;
- //long name of the related policy operation
- operationSelectionLongName = stateEnumerationItem.getLongName();
- for (IPolicyEnumerationList relatedPolicyEnumerationItem : relatedPolicies) {
- dependantPolicyShortName = relatedPolicyEnumerationItem
- .getPolicy().getDescriptor().getShortName();
- //the list of related sp states that satisfy the stateEnumerationItem
- List<IStateEnumerationItem> relatedSPStateEnumerationList = relatedPolicyEnumerationItem
- .getEnumerationList();
- //the list of valid ids for the related service policy operation
- List<String> validIds = new Vector<String>();
- for (int i = 0; i < relatedSPStateEnumerationList
- .size(); i++) {
- validIds
- .add(relatedSPStateEnumerationList
- .get(i).getId());
-
- }
- //get the current value of the related service policy default operation
- String currentItemID = ""; //$NON-NLS-1$
- List<IPolicyOperation> relatedServicePolicyPolicyOperationsList = platformUI.getOperations(relatedPolicyEnumerationItem.getPolicy(), project ==null);
- IPolicyOperation relatedPolicyOperationItem = null;
- for (IPolicyOperation relatedServicePolicyPolicyOperationItem : relatedServicePolicyPolicyOperationsList) {
- if (relatedServicePolicyPolicyOperationItem.isUseDefaultData()) {
- currentItemID = relatedServicePolicyPolicyOperationItem.getStateItem(project);
- relatedPolicyOperationItem = relatedServicePolicyPolicyOperationItem;
- break;
- }
- }
-
- if (!validIds
- .contains(currentItemID)) {
- // policy state is invalid
- IStatus error = createUnsatisfiedRelationshipError(sp,
- operationLongName,
- operationSelectionLongName,
- dependantPolicyShortName,
- relatedPolicyOperationItem,
- relatedSPStateEnumerationList);
- allErrors.put(sp.getId(), error);
-
- }
-
-
- }
-
- }
-
- }
- }
-
- List<IServicePolicy> servicePolicyChildrenList = sp.getChildren();
- for (IServicePolicy servicePolicyChildrenItem : servicePolicyChildrenList) {
- validatePolicy(servicePolicyChildrenItem);
-
- }
-
- }
-
- /**
- * Sets the icon for the ti denoting it as valid
- * @param ti a valid tree item
- */
- private void setValidPolicyState(TreeItem ti) {
- IServicePolicy sp = (IServicePolicy) ti.getData();
- setImage(ti, sp, getIconOverlayInfo(sp, false));
- }
-
- /**
- * Sets the icon for ti denoting it as invalid, as well as ti's parent tree items
- * @param ti an invalid tree item
- * @param updateDetailsOnly true indicates do not update parent tree items only in master tree
- */
- private void setInvalidPolicyState(TreeItem ti, boolean updateDetailsOnly) {
- IServicePolicy SP = (IServicePolicy) ti.getData();
- setImage(ti, SP, getIconOverlayInfo(SP, true));
- TreeItem parent;
- if (ti.getParent() == masterPolicyTree || updateDetailsOnly)
- parent = ti.getParentItem();
- else
- parent = (ti.getParentItem() == null && SP.getParentPolicy() != null) ? getParentInMasterTree(SP
- .getId())
- : ti.getParentItem();
- while (parent != null) {
- setImage(parent, (IServicePolicy) parent.getData(),
- getIconOverlayInfo((IServicePolicy) parent.getData(),
- true));
- if (updateDetailsOnly)
- parent = parent.getParentItem();
- else {
- parent = (parent.getParentItem() == null && ((IServicePolicy) parent
- .getData()).getParentPolicy() != null) ? getParentInMasterTree(((IServicePolicy) parent
- .getData()).getParentPolicy().getId())
- : parent.getParentItem();
- }
-
- }
- }
-
- /**
- * Creates an error status object for the sp. The error message contains information about
- * an unsatisfied relationship
- * @param sp
- * @param operationLongName
- * @param operationSelectionLongName
- * @param dependantPolicyShortName
- * @param relatedOperation
- * @param relatedOperationAcceptableValues
- * @return an Error status
- */
- private IStatus createUnsatisfiedRelationshipError(IServicePolicy sp,
- String operationLongName, String operationSelectionLongName,
- String dependantPolicyShortName,
- IPolicyOperation relatedOperation,
- List<IStateEnumerationItem> relatedOperationAcceptableValues) {
- String dependantOperationShortName;
- String dependantOperationSelectionShortNameList;
- dependantOperationShortName = relatedOperation
- .getDescriptor().getShortName();
- dependantOperationSelectionShortNameList = new String();
- for (int i = 0; i < relatedOperationAcceptableValues.size(); i++) {
- IStateEnumerationItem item = relatedOperationAcceptableValues.get(i);
- if (i != 0)
- dependantOperationSelectionShortNameList += " | "; //$NON-NLS-1$
- dependantOperationSelectionShortNameList += item.getShortName();
-
- }
- String[] args = { sp.getDescriptor().getLongName(), operationLongName,
- operationSelectionLongName, dependantPolicyShortName,
- dependantOperationShortName,
- dependantOperationSelectionShortNameList};
- IStatus error = new Status(Status.ERROR,
- ServicePolicyActivatorUI.PLUGIN_ID, NLS.bind(
- WstSPUIPluginMessages.SERVICEPOLICIES_DEPENDENCY_ERROR,
- args));
- return error;
- }
-
- /**
- * @param parentID the id to find in the master tree
- * @return a TreeItem with the id in the master tree
- */
- private TreeItem getParentInMasterTree(String parentID) {
- TreeItem parent = null;
- TreeItem[] rootNodes = masterPolicyTree.getItems();
- for (int i = 0; i < rootNodes.length; i++) {
- parent = findChildNode(rootNodes[i], parentID);
- if (parent != null)
- break;
- }
- return parent;
-
- }
-
- /**
- * Returns a TreeItem associated with a child policy of ti
- * @param ti
- * @param id the policy id of a child node of ti
- * @return null if there is no child policy matching id
- */
- private TreeItem findChildNode(TreeItem ti, String id) {
- TreeItem toReturn = null;
- if (((IServicePolicy) ti.getData()).getId().equals(id)) {
- toReturn = ti;
- } else {
- TreeItem[] childItems = ti.getItems();
- for (int i = 0; i < childItems.length; i++) {
- toReturn = findChildNode(childItems[i], id);
- }
-
- }
- return toReturn;
-
- }
-
- /**
- * Returns dependancy information about sp, that is information about
- * it's relationships (if any) with other service policies
- * @param sp the service policy to get dependency info about
- * @return
- */
- private String getDependanciesText(IServicePolicy sp) {
- // the relationships defined for the policy
- List<IPolicyRelationship> relationShipList = sp.getRelationships();
- if (relationShipList == null || relationShipList.size() == 0)
- return WstSPUIPluginMessages.SERVICEPOLICIES_DEPENDENCIES_NONE;
- String toReturn = new String();
-
- String operationLongName;
- String operationSelectionLongName;
- String dependantPolicyShortName;
- String dependantOperationShortName;
- String dependantOperationSelectionShortNameList;
-
- for (IPolicyRelationship relationShipItem : relationShipList) {
- List<IPolicyOperation> policyOperationsList = platformUI
- .getOperations(relationShipItem.getPolicyEnumerationList()
- .getPolicy(), project == null);
- operationLongName = ""; //$NON-NLS-1$
- for (IPolicyOperation policyOperationItem : policyOperationsList) {
- if (policyOperationItem.isUseDefaultData()) {
- operationLongName = policyOperationItem.getDescriptor()
- .getLongName();
- break;
- }
- }
- // policies associated with the relationship item
- List<IPolicyEnumerationList> relatedPolicies = relationShipItem
- .getRelatedPolicies();
- List<IStateEnumerationItem> spStateEnumerationList = relationShipItem
- .getPolicyEnumerationList().getEnumerationList();
- for (IStateEnumerationItem stateEnumerationItem : spStateEnumerationList) {
- operationSelectionLongName = stateEnumerationItem.getLongName();
- for (IPolicyEnumerationList relatedPolicyEnumerationItem : relatedPolicies) {
- dependantPolicyShortName = relatedPolicyEnumerationItem
- .getPolicy().getDescriptor().getShortName();
- List<IStateEnumerationItem> relatedSPStateEnumerationList = relatedPolicyEnumerationItem
- .getEnumerationList();
- List<IPolicyOperation> relatedPolicyOperationsList = platformUI
- .getOperations(relatedPolicyEnumerationItem
- .getPolicy(), (project == null));
- dependantOperationShortName = ""; //$NON-NLS-1$
- for (IPolicyOperation relatedPolicyOperationItem : relatedPolicyOperationsList) {
- if (relatedPolicyOperationItem.isUseDefaultData())
- dependantOperationShortName = relatedPolicyOperationItem
- .getDescriptor().getShortName();
- break;
- }
-
- dependantOperationSelectionShortNameList = new String();
- for (int i = 0; i < relatedSPStateEnumerationList.size(); i++) {
- IStateEnumerationItem item = relatedSPStateEnumerationList
- .get(i);
- if (i != 0)
- dependantOperationSelectionShortNameList += " | "; //$NON-NLS-1$
- dependantOperationSelectionShortNameList += item
- .getShortName();
-
- }
- String[] args = { operationLongName,
- operationSelectionLongName,
- dependantPolicyShortName,
- dependantOperationShortName,
- dependantOperationSelectionShortNameList };
- toReturn += NLS.bind(
- WstSPUIPluginMessages.SERVICEPOLICIES_DEPENDENCIES,
- args)
- + "\r\n"; //$NON-NLS-1$
-
- }
-
- }
-
- }
- return toReturn;
- }
-
-
- /**
- * Saves to the preference store the widget data (widget data contains all
- * service policy operations the control applies to)
- * @param actionControl a widget who's data needs to be saved to the preference store
- *
- */
- private void updatePolicy(Control actionControl) {
-
- List<IPolicyOperation> policyOperationList = ((ActionControlData) actionControl.getData()).getPoList();
- IPolicyOperation po0 = policyOperationList.get(0);
-
- List<IServicePolicy> servicePolicyList = ((ActionControlData) actionControl
- .getData()).getSpList();
- if (actionControl instanceof Button
- && po0.getOperationKind().equals(OperationKind.complex))
- updateComplexOperationPreference(po0, servicePolicyList);
- else
- for (IPolicyOperation policyOperationItem : policyOperationList) {
-
- updateSelectionOperationPreference(actionControl, policyOperationItem);
- }
-
- }
-
- public boolean okToLeave() {
- return allErrors.size() == 0;
-
- }
-
- /**
- * Saves value of enumeration, selection, and iconselection type operations
- * to the preference store
- * @param actionControl the action control containing the value to set for the preference
- * @param po
- * @param sp
- */
- private void updateSelectionOperationPreference(Control actionControl, IPolicyOperation po) {
- String selectedValue;
- if (actionControl instanceof Combo) {
- selectedValue = ((Combo) actionControl).getText();
- List<IStateEnumerationItem> enumItemList = ServicePolicyPlatform
- .getInstance().getStateEnumeration(po.getEnumerationId());
- for (IStateEnumerationItem enumItem : enumItemList) {
- if (enumItem.getLongName().equals(selectedValue)) {
- po.setStateItem(project, enumItem.getId());
- break;
- }
- }
-
- } else {
- if (((Button) actionControl).getSelection()) {
- po.setStateItem(project, "org.eclipse.wst.true"); //$NON-NLS-1$
- } else
- po.setStateItem(project, "org.eclipse.wst.false"); //$NON-NLS-1$
-
- }
-
- }
-
-
- /**
- * Launches the complex operation for the list of service policies
- * @param po a "complex" policy operation
- * @param sps a list of service policies to apply the operation to
- */
- private void updateComplexOperationPreference(IPolicyOperation po,
- List<IServicePolicy> sps) {
- //complex operations can result in added and deleted nodes, cache them until operation completed
- bComplexOpCompleted = false;
- listChildChangeEvents = new Vector<ChildChangeEvent>();
- try {
- po.launchOperation(sps);
- } catch (RuntimeException e) {
- //just want to make sure finally clause is executed so can update UI of additions/deletions
- } finally {
- bComplexOpCompleted =true;
- Hashtable<String, IServicePolicy> topLevelAdds = getHighestLevelChildren(listChildChangeEvents, true);
- for (ChildChangeEvent childChangeEventItem : listChildChangeEvents) {
- processChildChangeEvent(childChangeEventItem, topLevelAdds);
- }
-
- }
- }
- private Hashtable<String, IServicePolicy> getHighestLevelChildren (List<ChildChangeEvent> htChildChangeEvents, boolean forAddOnly) {
- Hashtable<String, IServicePolicy> toReturn = new Hashtable<String, IServicePolicy>();
- Iterator<ChildChangeEvent> elements = htChildChangeEvents.iterator();
- ChildChangeEvent next;
- Hashtable<String, IServicePolicy> allSps = new Hashtable<String, IServicePolicy>();
- while (elements.hasNext()) {
- next = elements.next();
- List<IServicePolicy> changedChildrenList = next.getChangedChildren();
- List<Boolean> addedList = next.getAdded();
- for (int i = 0; i < changedChildrenList.size(); i++) {
- if (forAddOnly && addedList.get(i).booleanValue() == true)
- allSps.put(changedChildrenList.get(i).getId(), changedChildrenList.get(i));
- }
- }
- Enumeration<IServicePolicy> servicePolicyElements = allSps.elements();
- IServicePolicy nextServicePolicyElement;
- while (servicePolicyElements.hasMoreElements()) {
- nextServicePolicyElement = servicePolicyElements.nextElement();
- if (nextServicePolicyElement.getParentPolicy() == null || !allSps.containsKey(nextServicePolicyElement.getParentPolicy().getId())) {
- toReturn.put(nextServicePolicyElement.getId(), nextServicePolicyElement);
- }
- }
- return toReturn;
- }
- public void dispose() {
- super.dispose();
- iconManager.dispose();
- }
-
- /**
- * Create UI widgets for operations applicable to the list of service policies sp
- * @param spList the list of service policies to create UI widgets, the UI widgets
- * will be used to define operations/preferences to apply to the service policies in the list
- */
- private void addActionButtons(List<IServicePolicy> spList) {
- // remove existing action controls
- Control[] toRemove = operationsComposite.getChildren();
- for (int i = 0; i < toRemove.length; i++) {
- toRemove[i].dispose();
- }
- List<List<IPolicyOperation>> policyOperationListList = platformUI.getOperationsList(spList, (project == null));
-
- for (List<IPolicyOperation> policyOperationList : policyOperationListList) {
- if (policyOperationList.size() > 0) {
- if (policyOperationList.get(0).getOperationKind() == IPolicyOperation.OperationKind.complex) {
- addComplexOperationUI(policyOperationList, spList);
- } else
- addSelectionOperationUI(policyOperationList, spList);
- }
-
- }
- // just removed and added some controls so force composite
- // to re-layout it's controls
- operationsScrolledComposite.setMinSize(operationsComposite.computeSize(
- SWT.DEFAULT, SWT.DEFAULT));
- operationsComposite.layout();
- }
- /**
- * Creates UI widgets for policy operations of enumeration, selection, and
- * iconselection types
- * @param po the policy operation to create a UI widget for
- * @param sp the service policies this operation will apply to
- */
- private void addSelectionOperationUI(List<IPolicyOperation> pos, List<IServicePolicy> sps) {
- //use the first operation instance in the list for data
- IPolicyOperation po0 = pos.get(0);
- //IServicePolicy sp0 = pos.get(0).getServicePolicy();
- IDescriptor d = po0.getDescriptor();
- Control selectionControl;
- if (po0.getOperationKind() == IPolicyOperation.OperationKind.enumeration) {
- Label l = new Label(operationsComposite, SWT.NONE);
- l.setText(d.getLongName() + ":"); //$NON-NLS-1$
- Combo cb = new Combo(operationsComposite, SWT.DROP_DOWN
- | SWT.READ_ONLY);
- selectionControl = cb;
- cb.addSelectionListener(this);
- List<IStateEnumerationItem> enumItemList = ServicePolicyPlatform
- .getInstance().getStateEnumeration(po0.getEnumerationId());
- for (IStateEnumerationItem enumItem : enumItemList) {
- cb.add(enumItem.getLongName());
- }
- l.setEnabled(po0.isEnabled(sps));
- cb.setEnabled(po0.isEnabled(sps));
- if (cb.isEnabled())
- cb.setText(getEnumerationOperationCurrentSelection(po0));
- } else {
- // a selection or icon
- Button checkBox = new Button(operationsComposite, SWT.CHECK);
- selectionControl = checkBox;
- checkBox.addSelectionListener(this);
- GridData checkBoxGD = new GridData();
- checkBoxGD.horizontalSpan = 2;
- checkBox.setLayoutData(checkBoxGD);
- checkBox.setText(d.getLongName());
- checkBox.setEnabled(po0.isEnabled(sps));
- if (checkBox.isEnabled())
- checkBox
- .setSelection(getSelectionOperationCurrentSelection(po0));
-
- }
-
- selectionControl.setData(new ActionControlData(sps, pos));
-
- }
- /**
- * @param sp a service policy with a selection or iconselection operation defined
- * @return true if the operation is currently selected
- */
- private boolean getSelectionOperationCurrentSelection(IPolicyOperation po) {
- return po.getStateItem(project).equals("org.eclipse.wst.true") ? true : false; //$NON-NLS-1$
-
- }
-
- /**
- * @param sp a service policy with an enumeration operation defined
- * @return the currently selected enumeration item
- */
- private String getEnumerationOperationCurrentSelection(IPolicyOperation po) {
- String currentSelection = ""; //$NON-NLS-1$
- List<IStateEnumerationItem> enumItemList = ServicePolicyPlatform
- .getInstance().getStateEnumeration(po.getEnumerationId());
- for (IStateEnumerationItem enumItem : enumItemList) {
- if (enumItem.getId().equals(po.getStateItem(project))) {
- currentSelection = enumItem.getLongName();
- break;
- }
- }
- return currentSelection;
- }
-
- /**
- * Creates UI widgets for policy operations of complex type
- * @param po the policy operation to create a UI widget for
- * @param sps the service policies this operation will apply to
- */
- private void addComplexOperationUI(List<IPolicyOperation> pos,
- List<IServicePolicy> sps) {
- IPolicyOperation po0 = pos.get(0);
- IDescriptor d = po0.getDescriptor();
- Button pushButton = new Button(operationsComposite, SWT.PUSH);
- GridData pushButtonGD = new GridData();
- pushButtonGD.horizontalSpan = 2;
- pushButton.setLayoutData(pushButtonGD);
- pushButton.setText(d.getLongName());
- pushButton.addSelectionListener(this);
- pushButton.setData(new ActionControlData(sps, pos));
- pushButton.setEnabled(po0.isEnabled(sps));
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetDefaultSelected(SelectionEvent e) {
-
- }
-
- /**
- * @return the error that should be shown, if there are multiple validation errors,
- * return the validation error for a service policy that just changes state (often the
- * selected service policy)
- */
- public IStatus getError() {
- return error;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/ServicePolicyPlatformUIImpl.java b/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/ServicePolicyPlatformUIImpl.java
deleted file mode 100644
index a01df64df..000000000
--- a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/ServicePolicyPlatformUIImpl.java
+++ /dev/null
@@ -1,194 +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
- * -------- -------- -----------------------------------------------------------
- * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk, Initial coding of service policy
- *******************************************************************************/
-package org.eclipse.wst.ws.internal.service.policy.ui;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.wst.ws.service.policy.IServicePolicy;
-import org.eclipse.wst.ws.service.policy.ServicePolicyPlatform;
-import org.eclipse.wst.ws.service.policy.listeners.IPolicyChildChangeListener;
-import org.eclipse.wst.ws.service.policy.ui.IPolicyOperation;
-import org.eclipse.wst.ws.service.policy.ui.IQuickFixActionInfo;
-
-public class ServicePolicyPlatformUIImpl
-{
- private Map<String, BaseOperationImpl> baseOperationMap;
- private Map<IServicePolicy, Set<IPolicyOperation>> policyCache;
- private Map<String,List<IQuickFixActionInfo>> quickFixes;
-
- public ServicePolicyPlatformUIImpl()
- {
- ServicePolicyPlatform platform = ServicePolicyPlatform.getInstance();
- ServicePolicyRegistryUI registry = new ServicePolicyRegistryUI();
- Set<String> policyIds = platform.getAllPolicyIds();
-
- baseOperationMap = new HashMap<String, BaseOperationImpl>();
- policyCache = new HashMap<IServicePolicy, Set<IPolicyOperation>>();
- quickFixes = new HashMap<String, List<IQuickFixActionInfo>>();
- registry.load( baseOperationMap, quickFixes );
- createOperationCache( policyIds );
-
- platform.addChildChangeListener( new ChildListener() );
- }
-
- public List<IQuickFixActionInfo> getQuickFixes( IStatus status )
- {
- String pluginId = status.getPlugin();
- int code = status.getCode();
- String key = pluginId + ":" + code; //$NON-NLS-1$
- List<IQuickFixActionInfo> result = quickFixes.get( key );
-
- if( result == null )
- {
- result = new Vector<IQuickFixActionInfo>();
- quickFixes.put( key, result );
- }
-
- return result;
- }
-
- public List<IPolicyOperation> getAllOperations()
- {
- List<IPolicyOperation> operations = new Vector<IPolicyOperation>();
-
- for( Set<IPolicyOperation> operationSet : policyCache.values() )
- {
- operations.addAll( operationSet );
- }
-
- return operations;
- }
-
- public Set<IPolicyOperation> getOperationsForPolicy( IServicePolicy policy, boolean isWorkspace )
- {
- Set<IPolicyOperation> policyOperations = policyCache.get( policy );
- Set<IPolicyOperation> result = new HashSet<IPolicyOperation>();
-
- if( policyOperations != null )
- {
- result.addAll( policyOperations );
-
- if( !isWorkspace )
- {
- for( IPolicyOperation operation : policyOperations )
- {
- if( operation.isWorkspaceOnly() )
- {
- result.remove( operation );
- }
- }
- }
- }
-
- return result;
- }
-
- public List<List<IPolicyOperation>> getOperationsList( List<IServicePolicy> policies, boolean isWorkspace )
- {
- Map<String, List<IPolicyOperation>> operationMap = new HashMap<String, List<IPolicyOperation>>();
-
- for( IServicePolicy policy : policies )
- {
- Set<IPolicyOperation> operations = policyCache.get( policy );
-
- if( operations != null )
- {
- for( IPolicyOperation operation : operations )
- {
- String id = operation.getId();
- List<IPolicyOperation> entryList = operationMap.get( id );
-
- if( entryList == null )
- {
- entryList = new Vector<IPolicyOperation>();
- operationMap.put( id, entryList );
- }
-
- entryList.add( operation );
- }
- }
- }
-
- return new Vector<List<IPolicyOperation>>( operationMap.values() );
- }
-
- private void createOperationCache( Set<String> policyIds )
- {
- ServicePolicyPlatform platform = ServicePolicyPlatform.getInstance();
- Collection<BaseOperationImpl> operations = baseOperationMap.values();
-
- for( BaseOperationImpl operation : operations )
- {
- String policyPattern = operation.getPolicyIdPattern();
- Pattern pattern = Pattern.compile( policyPattern );
-
- for( String policyId : policyIds )
- {
- Matcher matcher = pattern.matcher( policyId );
-
- if( matcher.matches() )
- {
- IServicePolicy policy = platform.getServicePolicy( policyId );
- Set<IPolicyOperation> operationsSet = policyCache.get(policy);
-
- if( operationsSet == null )
- {
- operationsSet = new HashSet<IPolicyOperation>();
- policyCache.put( policy, operationsSet );
- }
-
- operationsSet.add( new PolicyOperationImpl( operation, policy ) );
- }
- }
- }
- }
-
- private class ChildListener implements IPolicyChildChangeListener
- {
- public void childChange(List<IServicePolicy> childList, List<Boolean> addedList)
- {
- Set<String> idSet = new HashSet<String>();
-
- for( int index = 0; index < childList.size(); index++ )
- {
- IServicePolicy policy = childList.get( index );
- boolean added = addedList.get( index );
-
- if( added )
- {
-
- idSet.add( policy.getId() );
- }
- else
- {
- policyCache.remove( policy );
- }
- }
-
- if( idSet.size() > 0 )
- {
- createOperationCache( idSet );
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/ServicePolicyRegistryUI.java b/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/ServicePolicyRegistryUI.java
deleted file mode 100644
index cb1f6891d..000000000
--- a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/ServicePolicyRegistryUI.java
+++ /dev/null
@@ -1,288 +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
- * -------- -------- -----------------------------------------------------------
- * 20071024 196997 pmoogk@ca.ibm.com - Peter Moogk
- *******************************************************************************/
-package org.eclipse.wst.ws.internal.service.policy.ui;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.ws.service.policy.IDescriptor;
-import org.eclipse.wst.ws.service.policy.ui.IQuickFixActionInfo;
-import org.eclipse.wst.ws.service.policy.ui.ServicePolicyActivatorUI;
-import org.eclipse.wst.ws.service.policy.utils.RegistryUtils;
-
-public class ServicePolicyRegistryUI
-{
- private final String SERVICE_POLICY_ID = ServicePolicyActivatorUI.PLUGIN_ID + ".servicepolicyui"; //$NON-NLS-1$
-
- public ServicePolicyRegistryUI()
- {
- }
-
- public void load( Map<String, BaseOperationImpl> operationMap, Map<String, List<IQuickFixActionInfo>> quickFixes )
- {
- IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(SERVICE_POLICY_ID);
-
- for( IConfigurationElement element : elements )
- {
- String elementName = element.getName().toLowerCase();
-
- if( elementName.equals( "servicepolicyui") ) //$NON-NLS-1$
- {
- IConfigurationElement[] children = element.getChildren();
-
- for( IConfigurationElement child : children )
- {
- String name = child.getName().toLowerCase();
-
- if( name.equals( "operation" ) ) //$NON-NLS-1$
- {
- loadServicePolicyui( child, operationMap );
- }
- else if( name.equals( "quickfix") ) //$NON-NLS-1$
- {
- loadQuickFix( child, quickFixes );
- }
- else
- {
- error( "Undefined service policy ui element, " + name + " found." ); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
- else
- {
- error( "Undefined service policy ui element, " + elementName + " found." ); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-
- private void loadServicePolicyui( IConfigurationElement element,
- Map<String, BaseOperationImpl> operationMap )
- {
- String id = RegistryUtils.getAttribute( element, "id" ); //$NON-NLS-1$
- String policyPattern = RegistryUtils.getAttribute( element, "policypattern" ); //$NON-NLS-1$
- String workspaceOnly = RegistryUtils.getAttribute( element, "workspaceonly" ); //$NON-NLS-1$
- String useDefaultString = RegistryUtils.getAttribute( element, "defaultdata" ); //$NON-NLS-1$
- IConfigurationElement[] children = element.getChildren();
- IDescriptor descriptor = null;
- String enumId = null;
- String defaultItem = null;
- boolean selection = false;
- boolean icon = false;
- boolean multiSelect = false;
- IConfigurationElement enabledElement = null;
- IConfigurationElement launchElement = null;
- boolean error = false;
- boolean useDefaultData = true;
-
- if( useDefaultString != null )
- {
- useDefaultData = useDefaultString.equals( "true" ); //$NON-NLS-1$
- }
-
- for( IConfigurationElement child : children )
- {
- String name = child.getName().toLowerCase();
-
- if( name.equals( "descriptor" ) ) //$NON-NLS-1$
- {
- descriptor = RegistryUtils.loadDescriptor( child );
- }
- else if( name.equals( "enumeration" ) ) //$NON-NLS-1$
- {
- enumId = RegistryUtils.getAttribute( child, "id" ); //$NON-NLS-1$
- defaultItem = RegistryUtils.getAttribute( child, "defaultitem" ); //$NON-NLS-1$
-
- if( enumId == null )
- {
- error( "Service policy ui enumeration element is missing id attribute." ); //$NON-NLS-1$
- error = true;
- }
- }
- else if( name.equals( "selection" ) ) //$NON-NLS-1$
- {
- String iconValue = RegistryUtils.getAttribute( child, "icon" ); //$NON-NLS-1$
-
- selection = true;
-
- if( iconValue != null && iconValue.equalsIgnoreCase( "true" ) ) //$NON-NLS-1$
- {
- icon = true;
- useDefaultData = true;
- }
- }
- else if( name.equals( "complex" ) ) //$NON-NLS-1$
- {
- String launchClass = RegistryUtils.getAttribute( child, "launchclass" ); //$NON-NLS-1$
-
- if( launchClass == null )
- {
- error( "Service policy ui enumeration element is missing id attribute." ); //$NON-NLS-1$
- error = true;
- }
-
- launchElement = child;
- }
- else if( name.equals( "enabled" ) ) //$NON-NLS-1$
- {
- String multiSelectValue = RegistryUtils.getAttribute( child, "multiselect" ).toLowerCase(); //$NON-NLS-1$
-
- if( multiSelectValue != null && multiSelectValue.equals( "true" )) //$NON-NLS-1$
- {
- multiSelect = true;
- }
-
- String enabledClass = RegistryUtils.getAttribute( child, "enabledclass" ); //$NON-NLS-1$
-
- if( enabledClass != null )
- {
- enabledElement = child;
- }
- }
- else
- {
- error( "Undefined service policy ui element, " + name + " found." ); //$NON-NLS-1$ //$NON-NLS-2$
- error = true;
- }
- }
-
- if( descriptor == null )
- {
- error( "Service policy operation element must have a descriptor element defined." ); //$NON-NLS-1$
- error = true;
- }
-
- if( id == null )
- {
- error( "Id attribute not specified in service policy ui operation element." ); //$NON-NLS-1$
- error = true;
- }
-
- if( policyPattern == null )
- {
- error( "Id attribute not specified in service policy ui operation element." ); //$NON-NLS-1$
- error = true;
- }
-
- if( ( enumId == null && !selection && launchElement == null) ||
- ( enumId != null && (selection || launchElement != null)) ||
- ( selection && (enumId != null || launchElement != null)) ||
- ( launchElement != null && (selection && enumId != null)))
- {
- error( "Service policy operation element must have either an enumeration element or a selection element or a complex element" ); //$NON-NLS-1$
- error = true;
- }
-
- if( ! error )
- {
- BaseOperationImpl operation = new BaseOperationImpl();
- boolean workspaceOnlyValue = workspaceOnly != null && workspaceOnly.equals( "true" ); //$NON-NLS-1$
-
- operation.setId( id );
- operation.setPolicyIdPattern( policyPattern );
- operation.setDescriptor( descriptor );
- operation.setMultiSelect( multiSelect );
- operation.setEnumerationId( enumId );
- operation.setWorkspaceOnly( workspaceOnlyValue );
- operation.setUseDefaultData( useDefaultData );
-
- if( defaultItem != null )
- {
- operation.setDefaultItem( defaultItem );
- }
-
- if( selection )
- {
- operation.setEnumerationId( "org.eclipse.wst.service.policy.booleanEnum" ); //$NON-NLS-1$
- operation.setSelection( icon );
- }
-
- if( launchElement != null )
- {
- operation.setComplexElement( launchElement );
- }
-
- if( enabledElement != null )
- {
- operation.setEnabledElement( enabledElement );
- }
-
- operationMap.put( id, operation );
- }
- }
-
- private void loadQuickFix( IConfigurationElement element, Map<String, List<IQuickFixActionInfo>> quickFixes )
- {
- IConfigurationElement[] children = element.getChildren( "action" ); //$NON-NLS-1$
- String pluginId = RegistryUtils.getAttribute( element, "pluginid" ); //$NON-NLS-1$
- String code = RegistryUtils.getAttribute( element, "code" ); //$NON-NLS-1$
- List<IQuickFixActionInfo> fixList = new Vector<IQuickFixActionInfo>();
-
- for( IConfigurationElement child : children )
- {
- loadAction( child, fixList );
- }
-
- if( pluginId == null )
- {
- error( "Missing pluginId attribute for Service policy UI quick fix extension" ); //$NON-NLS-1$
- return;
- }
-
- if( code == null )
- {
- error( "Missing code attribute for Service policy UI quick fix extension" ); //$NON-NLS-1$
- return;
- }
-
- if( fixList.size() == 0 )
- {
- error( "Missing action element for Service policy UI quick fix extension" ); //$NON-NLS-1$
- return;
- }
-
- String key = pluginId + ":" + code; //$NON-NLS-1$
- quickFixes.put( key, fixList );
- }
-
- private void loadAction( IConfigurationElement element, List<IQuickFixActionInfo> fixList )
- {
- IConfigurationElement[] descElem = element.getChildren( "descriptor" ); //$NON-NLS-1$
- String clazz = RegistryUtils.getAttribute( element, "class" ); //$NON-NLS-1$
-
- if( descElem == null )
- {
- error( "Missing descriptor element for Service policy UI quick fix extension" ); //$NON-NLS-1$
- return;
- }
-
- if( clazz == null )
- {
- error( "Missing class attribute for Service policy UI quick fix extension" ); //$NON-NLS-1$
- return;
- }
-
- IDescriptor descriptor = RegistryUtils.loadDescriptor( element );
- QuickFixActionInfoImpl action = new QuickFixActionInfoImpl( element, descriptor );
-
- fixList.add( action );
- }
-
- private void error( String message )
- {
- ServicePolicyActivatorUI.logError( message, null );
- }
-}
diff --git a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/WstSPUIPluginMessages.java b/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/WstSPUIPluginMessages.java
deleted file mode 100644
index c2863bede..000000000
--- a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/WstSPUIPluginMessages.java
+++ /dev/null
@@ -1,48 +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
- * -------- -------- -----------------------------------------------------------
- * 20071025 196997 ericdp@ca.ibm.com - Eric Peters
- * 20071107 196997 ericdp@ca.ibm.com - Eric Peters
- * 20071120 209858 ericdp@ca.ibm.com - Eric Peters, Enhancing service policy framework and UI
- * 20071212 209858 ericdp@ca.ibm.com - Eric Peters, Enhancing service policy framework and UI
- *******************************************************************************/
-package org.eclipse.wst.ws.internal.service.policy.ui;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class WstSPUIPluginMessages extends NLS {
-
- private static final String BUNDLE_NAME = "org.eclipse.wst.ws.internal.service.policy.ui.WstSPUIPluginMessages";//$NON-NLS-1$
-
- private WstSPUIPluginMessages() {
- // Do not instantiate
- }
-
- public static String LABEL_SERVICEPOLICIES_DESCRIPTION;
- public static String LABEL_SERVICEPOLICIES_DEPENDENCIES;
- public static String TOOLTIP_PSP_DESCRIPTION;
- public static String TOOLTIP_PSP_DEPENDENCIES;
- public static String TOOLTIP_PSP_TREE;
- public static String TOOLTIP_PSP_DETAILSTREE;
- public static String SERVICEPOLICIES_DEPENDENCIES;
- public static String SERVICEPOLICIES_DEPENDENCY_ERROR;
- public static String SERVICEPOLICIES_DEPENDENCIES_NONE;
- public static String LINK_CONFIGWORKSPACE_SETTINGS;
- public static String LABEL_ENABLE_PROJECT_SETTINGS;
- public static String LABEL_QFLINK;
- public static String TEXT_QFIX_NOSUG;
- public static String TEXT_DETAILS;
-
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, WstSPUIPluginMessages.class);
- }
-}
diff --git a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/WstSPUIPluginMessages.properties b/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/WstSPUIPluginMessages.properties
deleted file mode 100644
index c0c5e57f6..000000000
--- a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/WstSPUIPluginMessages.properties
+++ /dev/null
@@ -1,38 +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
-# -------- -------- -----------------------------------------------------------
-# 20071025 196997 ericdp@ca.ibm.com - Eric Peters
-# 20071107 196997 ericdp@ca.ibm.com - Eric Peters
-# 20071120 209858 ericdp@ca.ibm.com - Eric Peters, Enhancing service policy framework and UI
-# 20071212 209858 ericdp@ca.ibm.com - Eric Peters, Enhancing service policy framework and UI
-###############################################################################
-
-#
-# Service Policies Preference page
-#
-
-LABEL_SERVICEPOLICIES_DESCRIPTION=Description:
-LABEL_SERVICEPOLICIES_DEPENDENCIES=Dependencies:
-#example message below is Compliance level "Suggest compliance" requires WS-I AP 1.0 [ suggest|ignore ]
-SERVICEPOLICIES_DEPENDENCIES={0} \"{1}\" requires {2} {3} [{4}]
-#example message below is WS-I SSBP Compliance level "Suggest compliance" requires WS-I AP 1.0 [ suggest|ignore ]
-SERVICEPOLICIES_DEPENDENCY_ERROR= {0} {1} \"{2}\" requires {3} {4} [{5}]
-SERVICEPOLICIES_DEPENDENCIES_NONE=None
-TOOLTIP_PSP_DESCRIPTION=Description of selected tree node
-TOOLTIP_PSP_DEPENDENCIES=Dependencies of selected tree node
-TOOLTIP_PSP_TREE=Select a tree node and use the panel on the right to define related preferences
-TOOLTIP_PSP_DETAILSTREE=Select a tree node and use the panel below to define related preferences
-LABEL_QFLINK=Quick Fix
-TEXT_QFIX_NOSUG=No Suggestions. See the error message and any listed dependencies for {1} to resolve the error.
-TEXT_DETAILS=details
-LINK_CONFIGWORKSPACE_SETTINGS=Configure Workspace Settings...
-LABEL_ENABLE_PROJECT_SETTINGS=Enable project specific settings
-
diff --git a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/preferences/ServicePoliciesPreferencePage.java b/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/preferences/ServicePoliciesPreferencePage.java
deleted file mode 100644
index f97064674..000000000
--- a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/preferences/ServicePoliciesPreferencePage.java
+++ /dev/null
@@ -1,136 +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
- * -------- -------- -----------------------------------------------------------
- * 20071025 196997 ericdp@ca.ibm.com - Eric Peters
- * 20071107 196997 ericdp@ca.ibm.com - Eric Peters
- * 20071120 209858 ericdp@ca.ibm.com - Eric Peters, Enhancing service policy framework and UI
- *******************************************************************************/
-package org.eclipse.wst.ws.internal.service.policy.ui.preferences;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.wst.ws.internal.service.policy.ui.ServicePoliciesComposite;
-import org.eclipse.wst.ws.service.policy.ServicePolicyPlatform;
-
-public class ServicePoliciesPreferencePage extends PreferencePage implements
- IWorkbenchPreferencePage, SelectionListener
-
-{
- ServicePoliciesComposite preferencePage;
- Composite superParent;
- public static final String PAGE_ID = "org.eclipse.wst.ws.internal.ui.wsi.preferences.WSICompliancePreferencePage"; //$NON-NLS-1$
-
- /**
- * Creates preference page controls on demand.
- *
- * @param parentComposite
- * the parent for the preference page
- */
- protected Control createContents(Composite superparent) {
- preferencePage = new ServicePoliciesComposite(superparent, null, this);
- org.eclipse.jface.dialogs.Dialog.applyDialogFont(superparent);
- this.superParent = superparent;
- return preferencePage;
-
- }
-
- /**
- * Does anything necessary because the default button has been pressed.
- */
- protected void performDefaults() {
- preferencePage.performDefaults();
- IStatus error = preferencePage.getError();
- if (error == null) {
- super.setValid(true);
- super.setErrorMessage(null);
- } else {
- super.setErrorMessage(error.getMessage());
- super.setValid(false);
- }
- }
-
- /**
- * Do anything necessary because the OK button has been pressed.
- *
- * @return whether it is okay to close the preference page
- */
- public boolean performOk() {
- storeValues();
- return true;
- }
-
- /**
- * Stores the values of the controls back to the preference store.
- */
- private void storeValues() {
- ServicePolicyPlatform.getInstance().commitChanges();
- }
-
- /**
- * Do anything necessary because the Cancel button has been pressed.
- *
- * @return whether it is okay to close the preference page
- */
- public boolean performCancel() {
- ServicePolicyPlatform.getInstance().discardChanges();
- return true;
- }
-
- /**
- * Do anything necessary because the OK button has been pressed.
- *
- */
- protected void performApply() {
- storeValues();
- }
-
- /**
- * @see IWorkbenchPreferencePage
- */
- public void init(IWorkbench workbench) {
- }
-
- /**
- * @return whether it is okay to close the preference page
- */
- public boolean okToLeave() {
- return preferencePage.getError() == null;
-
- }
-
- public void dispose() {
- super.dispose();
- preferencePage.dispose();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
-
- }
-
- public void widgetSelected(SelectionEvent e) {
- IStatus error = preferencePage.getError();
- if (error == null) {
- super.setValid(true);
- super.setErrorMessage(null);
- } else {
- super.setErrorMessage(error.getMessage());
- super.setValid(false);
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/properties/ServicePoliciesPropertyPage.java b/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/properties/ServicePoliciesPropertyPage.java
deleted file mode 100644
index fca0af53b..000000000
--- a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/properties/ServicePoliciesPropertyPage.java
+++ /dev/null
@@ -1,311 +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
- * -------- -------- -----------------------------------------------------------
- * 20071107 196997 ericdp@ca.ibm.com - Eric Peters
- * 20071108 196997 ericdp@ca.ibm.com - Eric Peters
- * 20071120 209858 ericdp@ca.ibm.com - Eric Peters, Enhancing service policy framework and UI
- *******************************************************************************/
-package org.eclipse.wst.ws.internal.service.policy.ui.properties;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ControlEnableState;
-import org.eclipse.jface.dialogs.DialogPage;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.wst.ws.internal.service.policy.ui.ServicePoliciesComposite;
-import org.eclipse.wst.ws.internal.service.policy.ui.WstSPUIPluginMessages;
-import org.eclipse.wst.ws.internal.service.policy.ui.preferences.ServicePoliciesPreferencePage;
-import org.eclipse.wst.ws.service.policy.ServicePolicyPlatform;
-import org.eclipse.wst.ws.service.policy.ui.ServicePolicyActivatorUI;
-
-public class ServicePoliciesPropertyPage extends PropertyPage implements
- SelectionListener {
-
- private ServicePoliciesComposite propertyPage;
- private IProject project;
- public static final String PAGE_ID = "org.eclipse.wst.ws.internal.ui.wsi.properties.WSICompliancePropertyPage"; //$NON-NLS-1$
- private Button fUseProjectSettings;
- private Link fChangeWorkspaceSettings;
- private ControlEnableState fBlockEnableState;
- private Control fConfigurationBlockControl;
- private ServicePolicyPlatform platform = ServicePolicyPlatform
- .getInstance();
-
- public ServicePoliciesPropertyPage() {
- fBlockEnableState = null;
- }
-
- protected Control createContents(Composite superparent) {
- project = (IProject) getElement().getAdapter(IProject.class);
- boolean projectPrefsEnabled = platform
- .isProjectPreferencesEnabled(project);
- if (!projectPrefsEnabled) {
- //enable them so that service policies composite UI reflects
- //currently set project preferences, otherwise shows workspace
- //preferences and would need to redraw tree when user enables them
- platform.setProjectPreferencesEnabled(project, true);
- }
- propertyPage = new ServicePoliciesComposite(superparent, project, this);
- platform.setProjectPreferencesEnabled(project, projectPrefsEnabled);
- fConfigurationBlockControl = propertyPage;
- enablePreferenceContent(projectPrefsEnabled);
- fUseProjectSettings.setSelection(projectPrefsEnabled);
- updateLinkVisibility();
-
- org.eclipse.jface.dialogs.Dialog.applyDialogFont(superparent);
- return propertyPage;
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- propertyPage.widgetDefaultSelected(e);
- }
-
- public void dispose() {
- super.dispose();
- propertyPage.dispose();
- }
-
- public boolean okToLeave() {
- return propertyPage.getError() == null;
-
- }
-
- protected void performApply() {
- if (!fUseProjectSettings.getSelection()) {
- platform.setProjectPreferencesEnabled(project, false);
- }
- storeValues();
- }
-
- /**
- * Do anything necessary because the Cancel button has been pressed.
- * @return whether it is okay to close the preference page
- */
- public boolean performCancel() {
- platform.discardChanges(project);
- return true;
- }
-
- /**
- * Does anything necessary because the default button has been pressed.
- */
- protected void performDefaults() {
- enableProjectSpecificSettings(false);
- platform.setProjectPreferencesEnabled(project, false);
- propertyPage.performDefaults();
- IStatus error = propertyPage.getError();
- if (error == null) {
- super.setValid(true);
- super.setErrorMessage(null);
- } else {
- super.setErrorMessage(error.getMessage());
- super.setValid(false);
- }
-
- }
-
- /**
- * Do anything necessary because the OK button has been pressed.
- * @return whether it is okay to close the preference page
- */
- public boolean performOk() {
- if (!fUseProjectSettings.getSelection()) {
- platform.setProjectPreferencesEnabled(project, false);
- }
- storeValues();
- return true;
- }
-
- /**
- * Stores the values of the controls back to the preference store.
- */
- private void storeValues() {
- platform.commitChanges(project);
- }
-
- public void widgetSelected(SelectionEvent e) {
- IStatus error = propertyPage.getError();
- if (error == null) {
- super.setValid(true);
- super.setErrorMessage(null);
- } else {
- super.setErrorMessage(error.getMessage());
- super.setValid(false);
- }
-
- }
-
- protected Label createDescriptionLabel(Composite parent) {
- // fParentComposite= parent;
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setFont(parent.getFont());
- GridLayout layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.numColumns = 2;
- composite.setLayout(layout);
- composite
- .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- SelectionListener listener = new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent se) {
- }
-
- public void widgetSelected(SelectionEvent se) {
- enableProjectSpecificSettings(fUseProjectSettings
- .getSelection());
- platform.setProjectPreferencesEnabled(project,
- fUseProjectSettings.getSelection());
- }
- };
-
- fUseProjectSettings = new Button(composite, SWT.CHECK);
- fUseProjectSettings.addSelectionListener(listener);
- fUseProjectSettings
- .setText(WstSPUIPluginMessages.LABEL_ENABLE_PROJECT_SETTINGS);
- GridData gd = new GridData();
- gd.horizontalSpan = 1;
- gd.horizontalAlignment = GridData.FILL;
- fUseProjectSettings.setLayoutData(gd);
- fChangeWorkspaceSettings = createLink(composite,
- WstSPUIPluginMessages.LINK_CONFIGWORKSPACE_SETTINGS);
- fChangeWorkspaceSettings.setLayoutData(new GridData(SWT.END,
- SWT.CENTER, false, false));
-
- Label horizontalLine = new Label(composite, SWT.SEPARATOR
- | SWT.HORIZONTAL);
- horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
- true, false, 2, 1));
- horizontalLine.setFont(composite.getFont());
-
- return super.createDescriptionLabel(parent);
- }
-
- private Link createLink(Composite composite, String text) {
- Link link = new Link(composite, SWT.NONE);
- link.setFont(composite.getFont());
- link.setText("<A>" + text + "</A>"); //$NON-NLS-1$//$NON-NLS-2$
- link.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- openWorkspacePreferences((Link) e.widget);
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- openWorkspacePreferences((Link) e.widget);
- }
- });
- return link;
- }
-
- private void updateLinkVisibility() {
- if (fChangeWorkspaceSettings == null
- || fChangeWorkspaceSettings.isDisposed()) {
- return;
- }
-
- fChangeWorkspaceSettings.setEnabled(!useProjectSettings());
- }
-
- protected boolean useProjectSettings() {
- return fUseProjectSettings.getSelection();
- }
-
- protected void enablePreferenceContent(boolean enable) {
- if (enable) {
- if (fBlockEnableState != null) {
- fBlockEnableState.restore();
- fBlockEnableState = null;
- }
- } else {
- if (fBlockEnableState == null) {
- fBlockEnableState = ControlEnableState
- .disable(fConfigurationBlockControl);
- }
- }
- }
-
- protected void enableProjectSpecificSettings(
- boolean useProjectSpecificSettings) {
- fUseProjectSettings.setSelection(useProjectSpecificSettings);
- enablePreferenceContent(useProjectSpecificSettings);
- updateLinkVisibility();
- doStatusChanged();
- }
-
- protected void doStatusChanged() {
- if (useProjectSettings()) {
- IStatus status;
- status = (propertyPage.getError() == null) ? new Status(IStatus.OK,
- ServicePolicyActivatorUI.PLUGIN_ID, "") : propertyPage //$NON-NLS-1$
- .getError();
- updateStatus(status);
- } else {
- updateStatus(new Status(IStatus.OK,
- ServicePolicyActivatorUI.PLUGIN_ID, "")); //$NON-NLS-1$
- }
- }
-
- private void updateStatus(IStatus status) {
- boolean valid = (status == null || !status.matches(IStatus.ERROR));
- setValid(valid);
- applyToStatusLine(this, status);
- }
-
- /**
- * Applies the status to the status line of a dialog page.
- * @param page the dialog page
- * @param status the status to apply
- */
- public static void applyToStatusLine(DialogPage page, IStatus status) {
- String message = status.getMessage();
- if (message != null && message.length() == 0) {
- message = null;
- }
- switch (status.getSeverity()) {
- case IStatus.OK:
- page.setMessage(message, IMessageProvider.NONE);
- page.setErrorMessage(null);
- break;
- case IStatus.WARNING:
- page.setMessage(message, IMessageProvider.WARNING);
- page.setErrorMessage(null);
- break;
- case IStatus.INFO:
- page.setMessage(message, IMessageProvider.INFORMATION);
- page.setErrorMessage(null);
- break;
- default:
- page.setMessage(null);
- page.setErrorMessage(message);
- break;
- }
- }
-
- protected final void openWorkspacePreferences(Object data) {
- String id = ServicePoliciesPreferencePage.PAGE_ID;
- PreferencesUtil.createPreferenceDialogOn(getShell(), id,
- new String[] { id }, data).open();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/properties/ServicePolicyPropertyTester.java b/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/properties/ServicePolicyPropertyTester.java
deleted file mode 100644
index 94505bc36..000000000
--- a/bundles/org.eclipse.wst.ws.service.policy.ui/src/org/eclipse/wst/ws/internal/service/policy/ui/properties/ServicePolicyPropertyTester.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2005 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.wst.ws.internal.service.policy.ui.properties;
-
-import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.wst.ws.service.policy.ServicePolicyPlatform;
-
-public class ServicePolicyPropertyTester extends PropertyTester
-{
-
- public boolean test(Object receiver, String property, Object[] args, Object expectedValue)
- {
- return ServicePolicyPlatform.getInstance().isEnabled( receiver );
- }
-}

Back to the top