You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2015/04/02 18:14:28 UTC
svn commit: r1670931 [5/8] - in /directory/studio/trunk:
features/openldap.feature/ plugins/ plugins/openldap.acl.editor/
plugins/openldap.acl.editor/resources/
plugins/openldap.acl.editor/resources/icons/
plugins/openldap.acl.editor/resources/template...
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/OpenLdapAclWhoClauseWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/OpenLdapAclWhoClauseWidget.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/OpenLdapAclWhoClauseWidget.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/OpenLdapAclWhoClauseWidget.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,1105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.openldap.config.acl.widgets;
+
+
+import java.text.MessageFormat;
+
+import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BrowserWidget;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+import org.apache.directory.studio.openldap.config.acl.OpenLdapAclEditorPlugin;
+import org.apache.directory.studio.openldap.config.acl.OpenLdapAclEditorPluginConstants;
+import org.apache.directory.studio.openldap.config.acl.dialogs.OpenLdapAccessLevelDialog;
+import org.apache.directory.studio.openldap.config.acl.model.AclAccessLevel;
+import org.apache.directory.studio.openldap.config.acl.model.AclAccessLevelLevelEnum;
+import org.apache.directory.studio.openldap.config.acl.model.AclControlEnum;
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClause;
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseAnonymous;
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseDn;
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseDnAttr;
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseEnum;
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseGroup;
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseSaslSsf;
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseSelf;
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseSsf;
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseStar;
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseTlsSsf;
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseTransportSsf;
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseUsers;
+import org.apache.directory.studio.openldap.config.acl.widgets.composites.WhoClauseDnAttributeComposite;
+import org.apache.directory.studio.openldap.config.acl.widgets.composites.WhoClauseDnComposite;
+import org.apache.directory.studio.openldap.config.acl.widgets.composites.WhoClauseGroupComposite;
+import org.apache.directory.studio.openldap.config.acl.widgets.composites.WhoClauseSaslSsfComposite;
+import org.apache.directory.studio.openldap.config.acl.widgets.composites.WhoClauseSsfComposite;
+import org.apache.directory.studio.openldap.config.acl.widgets.composites.WhoClauseTlsSsfComposite;
+import org.apache.directory.studio.openldap.config.acl.widgets.composites.WhoClauseTransportSsfComposite;
+
+
+public class OpenLdapAclWhoClauseWidget extends BrowserWidget implements SelectionListener
+{
+ /** The array of clauses */
+ private Object[] clauses = new Object[]
+ {
+ new ClauseComboViewerName(),
+ AclWhoClauseEnum.STAR,
+ AclWhoClauseEnum.ANONYMOUS,
+ AclWhoClauseEnum.USERS,
+ AclWhoClauseEnum.SELF,
+ AclWhoClauseEnum.DN,
+ AclWhoClauseEnum.DNATTR,
+ AclWhoClauseEnum.GROUP,
+ AclWhoClauseEnum.SASL_SSF,
+ AclWhoClauseEnum.SSF,
+ AclWhoClauseEnum.TLS_SSF,
+ AclWhoClauseEnum.TRANSPORT_SSF
+ };
+
+ /** The array of access levels */
+ private Object[] accessLevels = new Object[]
+ {
+ new AccessLevelComboViewerName(),
+ AclAccessLevelLevelEnum.MANAGE,
+ AclAccessLevelLevelEnum.WRITE,
+ AclAccessLevelLevelEnum.READ,
+ AclAccessLevelLevelEnum.SEARCH,
+ AclAccessLevelLevelEnum.COMPARE,
+ AclAccessLevelLevelEnum.AUTH,
+ AclAccessLevelLevelEnum.DISCLOSE,
+ AclAccessLevelLevelEnum.NONE,
+ new AccessLevelComboViewerCustom()
+ };
+
+ /** The array of controls */
+ private Object[] controls = new Object[]
+ {
+ new ControlComboViewerName(),
+ AclControlEnum.STOP,
+ AclControlEnum.CONTINUE,
+ AclControlEnum.BREAK
+ };
+
+ /** The parent builder widget */
+ private OpenLdapAclWhoClausesBuilderWidget builderWidget;
+
+ /** The row index */
+ private int index;
+
+ /** The clause */
+ private AclWhoClause clause;
+
+ /** The current clause selection */
+ private Object currentClauseSelection = clauses[0];
+
+ /** The current access level selection */
+ private Object currentAccessLevelSelection = accessLevels[0];
+
+ /** The current control selection */
+ private Object currentControlSelection = controls[0];
+
+ /** The current custom access level */
+ private AclAccessLevel currentCustomAccessLevel;
+
+ // UI Widgets
+ private Composite composite;
+ private Composite configurationComposite;
+ private ComboViewer clauseComboViewer;
+ private ComboViewer accessLevelComboViewer;
+ private ComboViewer controlComboViewer;
+ private ToolBar toolbar;
+ private ToolItem addButton;
+ private ToolItem deleteButton;
+ private ToolItem moveUpButton;
+ private ToolItem moveDownButton;
+
+ // Listeners
+ /** The listener for the clause combo viewer */
+ private ISelectionChangedListener clauseComboViewerListener = new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ // Getting the selected clause
+ Object selection = ( ( StructuredSelection ) clauseComboViewer
+ .getSelection() ).getFirstElement();
+
+ // Only changing the UI when the selection is different
+ if ( currentClauseSelection != selection )
+ {
+ // Storing the current selection
+ currentClauseSelection = selection;
+
+ // Disposing the current composite
+ if ( ( configurationComposite != null ) && ( !configurationComposite.isDisposed() ) )
+ {
+ configurationComposite.dispose();
+ configurationComposite = null;
+ }
+
+ // Setting the clause from the current selection
+ setClause();
+
+ // Creating the configuration UI
+ createConfigurationUI();
+
+ // Notifying listeners
+ notifyListeners();
+ }
+ }
+ };
+
+ /** The listener for the access level combo viewer */
+ private ISelectionChangedListener accessLevelComboViewerListener = new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ // Getting the selected access level
+ Object selection = ( ( StructuredSelection ) accessLevelComboViewer
+ .getSelection() ).getFirstElement();
+
+ // Special case for the 'custom' item
+ if ( accessLevels[accessLevels.length - 1].equals( selection ) )
+ {
+ // Getting the current access level
+ AclAccessLevel accessLevel = null;
+ if ( clause != null )
+ {
+ accessLevel = clause.getAccessLevel();
+ }
+
+ // Opening a dialog to edit the access level
+ OpenLdapAccessLevelDialog accessLevelDialog = new OpenLdapAccessLevelDialog( accessLevel );
+ if ( accessLevelDialog.open() == OpenLdapAccessLevelDialog.OK )
+ {
+ // Getting the access level from the dialog
+ currentCustomAccessLevel = accessLevelDialog.getAccessLevel();
+ }
+ else
+ {
+ // The dialog has been canceled
+
+ // Only changing the UI when the selection is different
+ if ( currentAccessLevelSelection != selection )
+ {
+ accessLevelComboViewer.removeSelectionChangedListener( accessLevelComboViewerListener );
+ accessLevelComboViewer
+ .setSelection( new StructuredSelection( currentAccessLevelSelection ) );
+ accessLevelComboViewer.addSelectionChangedListener( accessLevelComboViewerListener );
+ }
+
+ // We exit here
+ return;
+ }
+ }
+
+ // Only changing the UI when the selection is different or we have a custom access level value to store
+ if ( ( currentAccessLevelSelection != selection ) || ( currentCustomAccessLevel != null ) )
+ {
+ // Storing the current selection
+ currentAccessLevelSelection = selection;
+
+ // Setting the access level from the current selection
+ setAccessLevel();
+
+ // Is it a simple access level?
+ AclAccessLevel accessLevel = clause.getAccessLevel();
+ if ( isSimple( accessLevel ) )
+ {
+ currentAccessLevelSelection = accessLevel.getLevel();
+ }
+ // Is it a custom access level?
+ else if ( isCustom( accessLevel ) )
+ {
+ currentAccessLevelSelection = accessLevels[accessLevels.length - 1];
+ }
+ // Bogus case
+ else
+ {
+ currentAccessLevelSelection = accessLevels[0];
+ }
+
+ // Setting the correct selection and refreshing the combo viewer to update the labels
+ accessLevelComboViewer.removeSelectionChangedListener( accessLevelComboViewerListener );
+ accessLevelComboViewer
+ .setSelection( new StructuredSelection( currentAccessLevelSelection ) );
+ accessLevelComboViewer.addSelectionChangedListener( accessLevelComboViewerListener );
+ accessLevelComboViewer.refresh();
+
+ // Notifying listeners
+ notifyListeners();
+ }
+ }
+ };
+
+ /** The listener for the control combo viewer */
+ private ISelectionChangedListener controlComboViewerListener = new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ // Getting the selected control
+ Object selection = ( ( StructuredSelection ) controlComboViewer
+ .getSelection() ).getFirstElement();
+
+ // Only changing the UI when the selection is different
+ if ( currentControlSelection != selection )
+ {
+ // Storing the current selection
+ currentControlSelection = selection;
+
+ // Setting the control from the current selection
+ setControl();
+
+ // Notifying listeners
+ notifyListeners();
+ }
+ }
+ };
+
+
+ /**
+ * Creates a new instance of OpenLdapAclWhoClauseWidget.
+ *
+ * @param builderWidget the parent builder widget
+ * @param index the row index
+ */
+ public OpenLdapAclWhoClauseWidget( OpenLdapAclWhoClausesBuilderWidget builderWidget, AclWhoClause clause, int index )
+ {
+ this.builderWidget = builderWidget;
+ this.clause = clause;
+ this.index = index;
+ }
+
+
+ public void create( Composite parent )
+ {
+ // Creating the widget base composite
+ composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
+
+ // Creating the top composites
+ Composite topComposite = BaseWidgetUtils.createColumnContainer( composite, 2, 1 );
+ Composite topSubComposite = BaseWidgetUtils.createColumnContainer( topComposite, 3, true, 1 );
+
+ // Creating the clause, access level and control combo viewers
+ createClauseComboViewer( topSubComposite );
+ createAccessLevelComboViewer( topSubComposite );
+ createControlComboViewer( topSubComposite );
+
+ // Creating the toolbar and buttons
+ createToolbarAndButtons( topComposite );
+
+ // Initializing the UI with the clause
+ initWithClause();
+
+ // Adding the listeners to the UI widgets
+ addListeners();
+ }
+
+
+ /**
+ * Initializes the UI with the clause
+ */
+ private void initWithClause()
+ {
+ if ( clause != null )
+ {
+ // Clause
+ currentClauseSelection = AclWhoClauseEnum.get( clause );
+
+ // Access Level
+ AclAccessLevel accessLevel = clause.getAccessLevel();
+ if ( accessLevel == null )
+ {
+ currentAccessLevelSelection = accessLevels[0];
+ }
+ else
+ {
+ // Is it a simple access level?
+ if ( isSimple( accessLevel ) )
+ {
+ currentAccessLevelSelection = accessLevel.getLevel();
+ }
+ // Is it a custom access level?
+ else if ( isCustom( accessLevel ) )
+ {
+ currentAccessLevelSelection = accessLevels[accessLevels.length - 1];
+ }
+ // Bogus case
+ else
+ {
+ currentAccessLevelSelection = accessLevels[0];
+ }
+ }
+
+ // Control
+ AclControlEnum control = clause.getControl();
+ if ( control == null )
+ {
+ currentControlSelection = controls[0];
+ }
+ else
+ {
+ currentControlSelection = control;
+ }
+ }
+ else
+ {
+ // Defaulting to the first row of the arrays
+ currentClauseSelection = clauses[0];
+ currentAccessLevelSelection = accessLevels[0];
+ currentControlSelection = controls[0];
+ }
+
+ // Setting the selection for the combo viewers
+ clauseComboViewer.setSelection( new StructuredSelection( currentClauseSelection ) );
+ accessLevelComboViewer.setSelection( new StructuredSelection( currentAccessLevelSelection ) );
+ controlComboViewer.setSelection( new StructuredSelection( currentControlSelection ) );
+ }
+
+
+ /**
+ * Indicates if the given access level is simple or not.
+ *
+ * @param accessLevel the access level
+ * @return <code>true</code> if the access level is simple,
+ * <code>false</code> if not
+ */
+ private boolean isSimple( AclAccessLevel accessLevel )
+ {
+ if ( accessLevel != null )
+ {
+ return ( !accessLevel.isSelf() ) && ( accessLevel.getLevel() != null );
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Indicates if the given access level is complex or not.
+ *
+ * @param accessLevel the access level
+ * @return <code>true</code> if the access complex is simple,
+ * <code>false</code> if not
+ */
+ private boolean isCustom( AclAccessLevel accessLevel )
+ {
+ if ( accessLevel != null )
+ {
+ return ( accessLevel.isSelf() )
+ || ( ( accessLevel.getPrivilegeModifier() != null ) && ( accessLevel.getPrivileges().size() > 0 ) );
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Creates the clause combo viewer.
+ *
+ * @param parent the parent composite
+ */
+ private void createClauseComboViewer( Composite parent )
+ {
+ clauseComboViewer = new ComboViewer( BaseWidgetUtils.createReadonlyCombo( parent, new String[0], -1, 1 ) );
+ clauseComboViewer.setContentProvider( new ArrayContentProvider() );
+ clauseComboViewer.setLabelProvider( new LabelProvider()
+ {
+ public String getText( Object element )
+ {
+ if ( element instanceof ClauseComboViewerName )
+ {
+ return "< Clause >";
+ }
+ else if ( element instanceof AclWhoClauseEnum )
+ {
+ AclWhoClauseEnum value = ( AclWhoClauseEnum ) element;
+ switch ( value )
+ {
+ case STAR:
+ return "Anyone (*)";
+ case ANONYMOUS:
+ return "Anonymous";
+ case USERS:
+ return "Users";
+ case SELF:
+ return "Self";
+ case DN:
+ return "DN";
+ case DNATTR:
+ return "DN in attribute";
+ case GROUP:
+ return "Group";
+ case SASL_SSF:
+ return "SASL SSF";
+ case SSF:
+ return "SSF";
+ case TLS_SSF:
+ return "TLS SSF";
+ case TRANSPORT_SSF:
+ return "Transport SSF";
+ }
+ }
+
+ return super.getText( element );
+ }
+ } );
+ clauseComboViewer.setInput( clauses );
+ clauseComboViewer.setSelection( new StructuredSelection( currentClauseSelection ) );
+ }
+
+
+ /**
+ * Creating the access level combo viewer.
+ *
+ * @param parent the parent composite
+ */
+ private void createAccessLevelComboViewer( Composite parent )
+ {
+ accessLevelComboViewer = new ComboViewer(
+ BaseWidgetUtils.createReadonlyCombo( parent, new String[0], -1, 1 ) );
+ accessLevelComboViewer.setContentProvider( new ArrayContentProvider() );
+ accessLevelComboViewer.setLabelProvider( new LabelProvider()
+ {
+ public String getText( Object element )
+ {
+ if ( element instanceof AccessLevelComboViewerName )
+ {
+ return "< Access Level >";
+ }
+ else if ( element instanceof AccessLevelComboViewerCustom )
+ {
+ if ( ( clause != null ) && ( isCustom( clause.getAccessLevel() ) ) )
+ {
+ return MessageFormat.format( "Custom... [{0}]", clause.getAccessLevel() );
+ }
+
+ return "Custom...";
+ }
+ else if ( element instanceof AclAccessLevelLevelEnum )
+ {
+ AclAccessLevelLevelEnum value = ( AclAccessLevelLevelEnum ) element;
+ switch ( value )
+ {
+ case MANAGE:
+ return "Manage";
+ case WRITE:
+ return "Write";
+ case READ:
+ return "Read";
+ case SEARCH:
+ return "Search";
+ case COMPARE:
+ return "Compare";
+ case AUTH:
+ return "Auth";
+ case DISCLOSE:
+ return "Disclose";
+ case NONE:
+ return "None";
+ }
+ }
+
+ return super.getText( element );
+ }
+ } );
+ accessLevelComboViewer.setInput( accessLevels );
+ accessLevelComboViewer.setSelection( new StructuredSelection( currentAccessLevelSelection ) );
+ }
+
+
+ /**
+ * Creates the control combo viewer.
+ *
+ * @param parent the parent composite
+ */
+ private void createControlComboViewer( Composite parent )
+ {
+ controlComboViewer = new ComboViewer(
+ BaseWidgetUtils.createReadonlyCombo( parent, new String[0], -1, 1 ) );
+ controlComboViewer.setContentProvider( new ArrayContentProvider() );
+ controlComboViewer.setLabelProvider( new LabelProvider()
+ {
+ public String getText( Object element )
+ {
+ if ( element instanceof ControlComboViewerName )
+ {
+ return "< Control >";
+ }
+ else if ( element instanceof AclControlEnum )
+ {
+ AclControlEnum value = ( AclControlEnum ) element;
+ switch ( value )
+ {
+ case STOP:
+ return "Stop";
+ case CONTINUE:
+ return "Continue";
+ case BREAK:
+ return "Break";
+ }
+ }
+
+ return super.getText( element );
+ }
+ } );
+ controlComboViewer.setInput( controls );
+ controlComboViewer.setSelection( new StructuredSelection( currentControlSelection ) );
+ }
+
+
+ /**
+ * Creates the toolbar and buttons.
+ *
+ * @param parent the parent composite
+ */
+ private void createToolbarAndButtons( Composite parent )
+ {
+ // Creating the toolbar
+ toolbar = new ToolBar( parent, SWT.HORIZONTAL );
+
+ // Creating the 'Add' button
+ addButton = new ToolItem( toolbar, SWT.PUSH );
+ addButton.setToolTipText( "Add" );
+ addButton.setImage( OpenLdapAclEditorPlugin.getDefault().getImage(
+ OpenLdapAclEditorPluginConstants.IMG_ADD ) );
+
+ // Creating the 'Delete' button
+ deleteButton = new ToolItem( toolbar, SWT.PUSH );
+ deleteButton.setToolTipText( "Delete" );
+ deleteButton.setImage( OpenLdapAclEditorPlugin.getDefault().getImage(
+ OpenLdapAclEditorPluginConstants.IMG_DELETE ) );
+
+ // Creating the 'Move Up' button
+ moveUpButton = new ToolItem( toolbar, SWT.PUSH );
+ moveUpButton.setToolTipText( "Move Up" );
+ moveUpButton.setImage( OpenLdapAclEditorPlugin.getDefault().getImage(
+ OpenLdapAclEditorPluginConstants.IMG_UP ) );
+ // Creating the 'Move Down' button
+ moveDownButton = new ToolItem( toolbar, SWT.PUSH );
+ moveDownButton.setToolTipText( "Move Down" );
+ moveDownButton.setImage( OpenLdapAclEditorPlugin.getDefault().getImage(
+ OpenLdapAclEditorPluginConstants.IMG_DOWN ) );
+ }
+
+
+ /**
+ * Adds the listeners to the UI widgets.
+ */
+ private void addListeners()
+ {
+ // Adding the selection listener for the clause combo viewer
+ clauseComboViewer.addSelectionChangedListener( clauseComboViewerListener );
+
+ // Adding the selection listener for the access level combo viewer
+ accessLevelComboViewer.addSelectionChangedListener( accessLevelComboViewerListener );
+
+ // Adding the selection listener for the control combo viewer
+ controlComboViewer.addSelectionChangedListener( controlComboViewerListener );
+
+ // Adding toolbar buttons listeners
+ addButton.addSelectionListener( this );
+ deleteButton.addSelectionListener( this );
+ moveUpButton.addSelectionListener( this );
+ moveDownButton.addSelectionListener( this );
+ }
+
+
+ /**
+ * Create the configuration UI.
+ */
+ private void createConfigurationUI()
+ {
+ if ( currentClauseSelection instanceof AclWhoClauseEnum )
+ {
+ AclWhoClauseEnum currentClauseSelectionValue = ( AclWhoClauseEnum ) currentClauseSelection;
+ switch ( currentClauseSelectionValue )
+ {
+ case STAR:
+ break; // Nothing to configure
+ case ANONYMOUS:
+ break; // Nothing to configure
+ case USERS:
+ break; // Nothing to configure
+ case SELF:
+ break; // Nothing to configure
+ case DN:
+ createUIWhoClauseDn();
+ break;
+ case DNATTR:
+ createUIWhoClauseDnAttr();
+ break;
+ case GROUP:
+ createUIWhoClauseGroup();
+ break;
+ case SASL_SSF:
+ createCompositeWhoClauseSaslSsf();
+ break;
+ case SSF:
+ createCompositeWhoClauseSsf();
+ break;
+ case TLS_SSF:
+ createCompositeWhoClauseTlsSsf();
+ break;
+ case TRANSPORT_SSF:
+ createCompositeWhoClauseTransportSsf();
+ break;
+ }
+ }
+ }
+
+
+ /**
+ * Creates the UI for the DN who clause.
+ */
+ private void createUIWhoClauseDn()
+ {
+ configurationComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+
+ WhoClauseDnComposite composite = new WhoClauseDnComposite( builderWidget.visualEditorComposite );
+ composite.createComposite( configurationComposite );
+ }
+
+
+ /**
+ * Creates the UI for the DN Attribute who clause.
+ */
+ private void createUIWhoClauseDnAttr()
+ {
+ configurationComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+
+ WhoClauseDnAttributeComposite composite = new WhoClauseDnAttributeComposite( builderWidget.visualEditorComposite );
+ composite.createComposite( configurationComposite );
+ }
+
+
+ /**
+ * Creates the UI for the Group who clause.
+ */
+ private void createUIWhoClauseGroup()
+ {
+ configurationComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+
+ WhoClauseGroupComposite composite = new WhoClauseGroupComposite( builderWidget.visualEditorComposite );
+ composite.createComposite( configurationComposite );
+ }
+
+
+ /**
+ * Creates the UI for the SASL SSF who clause.
+ */
+ private void createCompositeWhoClauseSaslSsf()
+ {
+ configurationComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+
+ WhoClauseSaslSsfComposite composite = new WhoClauseSaslSsfComposite( builderWidget.visualEditorComposite );
+ composite.createComposite( configurationComposite );
+ }
+
+
+ /**
+ * Creates the UI for the SSF who clause.
+ */
+ private void createCompositeWhoClauseSsf()
+ {
+ configurationComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+
+ WhoClauseSsfComposite composite = new WhoClauseSsfComposite( builderWidget.visualEditorComposite );
+ composite.createComposite( configurationComposite );
+ }
+
+
+ /**
+ * Creates the UI for the TLS SSF who clause.
+ */
+ private void createCompositeWhoClauseTlsSsf()
+ {
+ configurationComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+
+ WhoClauseTlsSsfComposite composite = new WhoClauseTlsSsfComposite( builderWidget.visualEditorComposite );
+ composite.createComposite( configurationComposite );
+ }
+
+
+ /**
+ * Creates the UI for the Transport SSF who clause.
+ */
+ private void createCompositeWhoClauseTransportSsf()
+ {
+ configurationComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+
+ WhoClauseTransportSsfComposite composite = new WhoClauseTransportSsfComposite(
+ builderWidget.visualEditorComposite );
+ composite.createComposite( configurationComposite );
+ }
+
+
+ /**
+ * Creates a basic access level.
+ *
+ * @param level the level
+ * @return a basic access level
+ */
+ private AclAccessLevel createBasicAccessLevel( AclAccessLevelLevelEnum level )
+ {
+ AclAccessLevel accessLevel = new AclAccessLevel();
+ accessLevel.setLevel( level );
+ return accessLevel;
+ }
+
+
+ /**
+ * Sets the clause from the current selection.
+ */
+ private void setClause()
+ {
+ if ( currentClauseSelection instanceof AclWhoClauseEnum )
+ {
+ AclWhoClauseEnum clauseSelection = ( AclWhoClauseEnum ) currentClauseSelection;
+
+ // Creating the clause associated with the selection
+ switch ( clauseSelection )
+ {
+ case STAR:
+ clause = new AclWhoClauseStar();
+ break;
+ case ANONYMOUS:
+ clause = new AclWhoClauseAnonymous();
+ break;
+ case USERS:
+ clause = new AclWhoClauseUsers();
+ break;
+ case SELF:
+ clause = new AclWhoClauseSelf();
+ break;
+ case DN:
+ clause = new AclWhoClauseDn();
+ break;
+ case DNATTR:
+ clause = new AclWhoClauseDnAttr();
+ break;
+ case GROUP:
+ clause = new AclWhoClauseGroup();
+ break;
+ case SASL_SSF:
+ clause = new AclWhoClauseSaslSsf();
+ break;
+ case SSF:
+ clause = new AclWhoClauseSsf();
+ break;
+ case TLS_SSF:
+ clause = new AclWhoClauseTlsSsf();
+ break;
+ case TRANSPORT_SSF:
+ clause = new AclWhoClauseTransportSsf();
+ break;
+ }
+
+ // Also setting access level and control
+ setAccessLevel();
+ setControl();
+ }
+ else
+ {
+ clause = null;
+ }
+ }
+
+
+ /**
+ * Sets the access level from the current selection.
+ */
+ private void setAccessLevel()
+ {
+ if ( currentAccessLevelSelection instanceof AclAccessLevelLevelEnum )
+ {
+ AclAccessLevelLevelEnum accessLevelSelection = ( AclAccessLevelLevelEnum ) currentAccessLevelSelection;
+
+ // Creating the access level associated with the selection
+ switch ( accessLevelSelection )
+ {
+ case MANAGE:
+ setAccessLevel( createBasicAccessLevel( AclAccessLevelLevelEnum.MANAGE ) );
+ break;
+ case WRITE:
+ setAccessLevel( createBasicAccessLevel( AclAccessLevelLevelEnum.WRITE ) );
+ break;
+ case READ:
+ setAccessLevel( createBasicAccessLevel( AclAccessLevelLevelEnum.READ ) );
+ break;
+ case SEARCH:
+ setAccessLevel( createBasicAccessLevel( AclAccessLevelLevelEnum.SEARCH ) );
+ break;
+ case COMPARE:
+ setAccessLevel( createBasicAccessLevel( AclAccessLevelLevelEnum.COMPARE ) );
+ break;
+ case AUTH:
+ setAccessLevel( createBasicAccessLevel( AclAccessLevelLevelEnum.AUTH ) );
+ break;
+ case DISCLOSE:
+ setAccessLevel( createBasicAccessLevel( AclAccessLevelLevelEnum.DISCLOSE ) );
+ break;
+ case NONE:
+ setAccessLevel( createBasicAccessLevel( AclAccessLevelLevelEnum.NONE ) );
+ break;
+ }
+ }
+ else if ( currentAccessLevelSelection instanceof AccessLevelComboViewerCustom )
+ {
+ setAccessLevel( currentCustomAccessLevel );
+ currentCustomAccessLevel = null;
+ }
+ else
+ {
+ // Resetting access level
+ setAccessLevel( null );
+ }
+ }
+
+
+ /**
+ * Sets the access level to the clause (if any).
+ *
+ * @param accessLevel the access level
+ */
+ private void setAccessLevel( AclAccessLevel accessLevel )
+ {
+ if ( clause != null )
+ {
+ clause.setAccessLevel( accessLevel );
+ }
+ }
+
+
+ /**
+ * Sets the control from the current selection
+ */
+ private void setControl()
+ {
+ if ( currentControlSelection instanceof AclControlEnum )
+ {
+ AclControlEnum controlSelection = ( AclControlEnum ) currentControlSelection;
+
+ // Creating the clause associated with the selection
+ switch ( controlSelection )
+ {
+ case STOP:
+ setControl( AclControlEnum.STOP );
+ break;
+ case CONTINUE:
+ setControl( AclControlEnum.CONTINUE );
+ break;
+ case BREAK:
+ setControl( AclControlEnum.BREAK );
+ break;
+ }
+ }
+ else
+ {
+ // Resetting control
+ setControl( null );
+ }
+ }
+
+
+ /**
+ * Sets the control to the clause (if any).
+ *
+ * @param control the control
+ */
+ private void setControl( AclControlEnum control )
+ {
+ if ( clause != null )
+ {
+ clause.setControl( control );
+ }
+ }
+
+
+ /**
+ * Gets the who clause.
+ *
+ * @return the who clause
+ */
+ public AclWhoClause getClause()
+ {
+ return clause;
+ }
+
+
+ /**
+ * Gets the row index.
+ *
+ * @return the row index
+ */
+ public int getIndex()
+ {
+ return index;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetSelected( SelectionEvent e )
+ {
+ Object source = e.getSource();
+
+ if ( source == addButton )
+ {
+ builderWidget.addNewClause( this );
+ }
+ else if ( source == deleteButton )
+ {
+ builderWidget.deleteClause( this );
+ }
+ else if ( source == moveUpButton )
+ {
+ builderWidget.moveUpClause( this );
+ }
+ else if ( source == moveDownButton )
+ {
+ builderWidget.moveDownClause( this );
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetDefaultSelected( SelectionEvent e )
+ {
+ // Nothing to do
+ }
+
+
+ /**
+ * Gets the 'Add' button.
+ *
+ * @return the 'Add' button
+ */
+ public ToolItem getAddButton()
+ {
+ return addButton;
+ }
+
+
+ /**
+ * Gets the 'Delete' button.
+ *
+ * @return the 'Delete' button
+ */
+ public ToolItem getDeleteButton()
+ {
+ return deleteButton;
+ }
+
+
+ /**
+ * Gets the 'Move Up' button.
+ *
+ * @return the 'Move Up' button
+ */
+ public ToolItem getMoveUpButton()
+ {
+ return moveUpButton;
+ }
+
+
+ /**
+ * Gets the 'Move Down' button.
+ *
+ * @return the 'Move Down button
+ */
+ public ToolItem getMoveDownButton()
+ {
+ return moveDownButton;
+ }
+
+
+ /**
+ * Disposes all created SWT widgets.
+ */
+ public void dispose()
+ {
+ // Composite
+ if ( ( composite != null ) && ( !composite.isDisposed() ) )
+ {
+ composite.dispose();
+ }
+
+ // Combo Viewer
+ if ( ( clauseComboViewer != null ) && ( clauseComboViewer.getCombo() != null )
+ && ( !clauseComboViewer.getCombo().isDisposed() ) )
+ {
+ clauseComboViewer.getCombo().dispose();
+ }
+
+ // Toolbar
+ if ( ( toolbar != null ) && ( !toolbar.isDisposed() ) )
+ {
+ toolbar.dispose();
+ }
+
+ // Configuration composite
+ if ( ( configurationComposite != null ) && ( !configurationComposite.isDisposed() ) )
+ {
+ configurationComposite.dispose();
+ }
+ }
+
+ /**
+ * A private object for the first row of the clause combo viewer.
+ */
+ class ClauseComboViewerName
+ {
+ }
+
+ /**
+ * A private object for the first row of the access level combo viewer.
+ */
+ private class AccessLevelComboViewerName
+ {
+ }
+
+ /**
+ * A private object for the last row of the access level combo viewer.
+ */
+ private class AccessLevelComboViewerCustom
+ {
+ }
+
+ /**
+ * A private object for the first row of the control combo viewer.
+ */
+ private class ControlComboViewerName
+ {
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/OpenLdapAclWhoClausesBuilderWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/OpenLdapAclWhoClausesBuilderWidget.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/OpenLdapAclWhoClausesBuilderWidget.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/OpenLdapAclWhoClausesBuilderWidget.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,324 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.openldap.config.acl.widgets;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+
+import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClause;
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseStar;
+
+
+public class OpenLdapAclWhoClausesBuilderWidget
+{
+ /** The visual editor composite */
+ protected OpenLdapAclVisualEditorComposite visualEditorComposite;
+
+ /** The list of clauses */
+ private List<AclWhoClause> clauses = new ArrayList<AclWhoClause>();
+
+ /** The list of widgets */
+ private List<OpenLdapAclWhoClauseWidget> clauseWidgets = new ArrayList<OpenLdapAclWhoClauseWidget>();
+
+ /** The list of separators */
+ private List<Label> separatorWidgets = new ArrayList<Label>();
+
+ // UI widgets
+ private Group whoGroup;
+
+
+ /**
+ * Creates a new instance of OpenLdapAclWhoClausesBuilderWidget.
+ *
+ * @param visualEditorComposite the visual editor composite
+ */
+ public OpenLdapAclWhoClausesBuilderWidget( OpenLdapAclVisualEditorComposite visualEditorComposite )
+ {
+ this.visualEditorComposite = visualEditorComposite;
+ }
+
+
+ /**
+ * Create the UI.
+ *
+ * @param parent the parent composite
+ */
+ public void create( Composite parent )
+ {
+ // Creating the who group
+ whoGroup = BaseWidgetUtils.createGroup( parent, "Acces by \"Who\"", 1 );
+ whoGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ }
+
+
+ /**
+ * Disposes the clause widgets.
+ */
+ private void disposeClausesWidgets()
+ {
+ // Disposing and removing clause widgets
+ for ( OpenLdapAclWhoClauseWidget clauseWidget : clauseWidgets.toArray( new OpenLdapAclWhoClauseWidget[0] ) )
+ {
+ clauseWidget.dispose();
+ clauseWidgets.remove( clauseWidget );
+ }
+
+ // Disposing and removing separators
+ for ( Label separator : separatorWidgets.toArray( new Label[0] ) )
+ {
+ separator.dispose();
+ separatorWidgets.remove( separator );
+ }
+ }
+
+
+ /**
+ * Creates the clause widgets.
+ */
+ private void createClauseWidgets()
+ {
+ // Checking the clauses
+ if ( clauses.size() == 0 )
+ {
+ // Adding at least one default clause
+ clauses.add( new AclWhoClauseStar() );
+ }
+
+ // Creating a widget for each clause
+ for ( int i = 0; i < clauses.size(); i++ )
+ {
+ // Creating a separator (except for the first row
+ if ( i != 0 )
+ {
+ Label separator = new Label( whoGroup, SWT.SEPARATOR | SWT.HORIZONTAL );
+ separator.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ separatorWidgets.add( separator );
+ }
+
+ // Creating the clause widget
+ OpenLdapAclWhoClauseWidget clauseWidget = new OpenLdapAclWhoClauseWidget( this, clauses.get( i ), i );
+ clauseWidget.create( whoGroup );
+ clauseWidget.addWidgetModifyListener( new WidgetModifyListener()
+ {
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ // Getting the source widget
+ OpenLdapAclWhoClauseWidget widget = ( OpenLdapAclWhoClauseWidget ) event.getSource();
+
+ // Updating the clause
+ clauses.remove( widget.getIndex() );
+ clauses.add( widget.getIndex(), widget.getClause() );
+
+ // Adjusting the layout of the visual editor composite
+ visualEditorComposite.layout( true, true );
+ }
+ } );
+
+ clauseWidgets.add( clauseWidget );
+ }
+
+ // Updating button states for specific rows (first, last and the case where there's only one row)
+ if ( clauseWidgets.size() == 1 )
+ {
+ // There's only one row
+ OpenLdapAclWhoClauseWidget widget = clauseWidgets.get( 0 );
+ widget.getDeleteButton().setEnabled( false );
+ widget.getMoveUpButton().setEnabled( false );
+ widget.getMoveDownButton().setEnabled( false );
+ }
+ else if ( clauseWidgets.size() > 1 )
+ {
+ // There are more than 1 row
+ OpenLdapAclWhoClauseWidget firstWidget = clauseWidgets.get( 0 );
+ firstWidget.getMoveUpButton().setEnabled( false );
+ OpenLdapAclWhoClauseWidget lastWidget = clauseWidgets.get( clauseWidgets.size() - 1 );
+ lastWidget.getMoveDownButton().setEnabled( false );
+ }
+ }
+
+
+ /**
+ * Refreshes the clause widgets.
+ */
+ private void refreshWhoClauseWidgets()
+ {
+ // Disposing previous widgets and creating new ones
+ disposeClausesWidgets();
+ createClauseWidgets();
+
+ // Adjusting the layout of the visual editor composite
+ visualEditorComposite.layout( true, true );
+ }
+
+
+ /**
+ * This method is called by a OpenLdapAclWhoClauseWidget when a
+ * row needs to be added.
+ *
+ * @param widget the source widget
+ */
+ protected void addNewClause( OpenLdapAclWhoClauseWidget widget )
+ {
+ // Adding a new clause underneath the selected widget
+ clauses.add( widget.getIndex() + 1, new AclWhoClauseStar() );
+
+ // Refreshing clauses widgets
+ refreshWhoClauseWidgets();
+ }
+
+
+ /**
+ * This method is called by a OpenLdapAclWhoClauseWidget when a
+ * row needs to be deleted.
+ *
+ * @param widget the source widget
+ */
+ protected void deleteClause( OpenLdapAclWhoClauseWidget widget )
+ {
+ // Deleting the selected widget
+ clauses.remove( clauses.get( widget.getIndex() ) );
+
+ // Refreshing clauses widgets
+ refreshWhoClauseWidgets();
+ }
+
+
+ /**
+ * This method is called by a OpenLdapAclWhoClauseWidget when a
+ * row needs to be moved up.
+ *
+ * @param widget the source widget
+ */
+ protected void moveUpClause( OpenLdapAclWhoClauseWidget widget )
+ {
+ // Swapping clauses
+ swapClauseIndexes( widget.getIndex(), widget.getIndex() - 1 );
+
+ // Refreshing clauses widgets
+ refreshWhoClauseWidgets();
+ }
+
+
+ /**
+ * This method is called by a OpenLdapAclWhoClauseWidget when a
+ * row needs to be moved down.
+ *
+ * @param widget the source widget
+ */
+ protected void moveDownClause( OpenLdapAclWhoClauseWidget widget )
+ {
+ // Swapping clauses
+ swapClauseIndexes( widget.getIndex(), widget.getIndex() + 1 );
+
+ // Refreshing clauses widgets
+ refreshWhoClauseWidgets();
+ }
+
+
+ /**
+ * Swaps (exchanges) the clauses at the given indexes.
+ *
+ * @param sourceIndex the source index
+ * @param destinationIndex the destination index
+ */
+ private void swapClauseIndexes( int sourceIndex, int destinationIndex )
+ {
+ // Getting clauses
+ AclWhoClause sourceClause = clauses.get( sourceIndex );
+ AclWhoClause destinationClause = clauses.get( destinationIndex );
+
+ // Swapping clauses
+ clauses.remove( sourceClause );
+ clauses.remove( destinationClause );
+ if ( sourceIndex > destinationIndex )
+ {
+ clauses.add( destinationIndex, sourceClause );
+ clauses.add( sourceIndex, destinationClause );
+ }
+ else
+ {
+ clauses.add( sourceIndex, destinationClause );
+ clauses.add( destinationIndex, sourceClause );
+ }
+ }
+
+
+ /**
+ * Sets the input.
+ *
+ * @param clauses the who clauses
+ */
+ public void setInput( List<AclWhoClause> clauses )
+ {
+ this.clauses.clear();
+ this.clauses.addAll( clauses );
+
+ refreshWhoClauseWidgets();
+ }
+
+
+ /**
+ * Sets the context.
+ *
+ * @param context the context
+ */
+ public void setContext( OpenLdapAclValueWithContext context )
+ {
+ System.out.println( "Set Context" );
+ }
+
+
+ /**
+ * Gets the clauses.
+ *
+ * @return the clauses
+ */
+ public List<AclWhoClause> getClauses()
+ {
+ return clauses;
+ }
+
+
+ /**
+ * Disposes all UI widgets.
+ */
+ public void dispose()
+ {
+ // Disposing the who group
+ if ( ( whoGroup != null ) && ( !whoGroup.isDisposed() ) )
+ {
+ whoGroup.dispose();
+ }
+
+ // Disposing the clause widgets
+ disposeClausesWidgets();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/AbstractClauseComposite.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/AbstractClauseComposite.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/AbstractClauseComposite.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/AbstractClauseComposite.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.openldap.config.acl.widgets.composites;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.eclipse.swt.widgets.Composite;
+
+
+/**
+ * A basic common abstract class implementing {@link ClauseComposite}.
+ */
+public abstract class AbstractClauseComposite<C> implements ClauseComposite<C>
+{
+ /** The clause */
+ protected C clause;
+
+ /** The visual editor composite */
+ protected Composite visualEditorComposite;
+
+ /** The connection */
+ protected IBrowserConnection connection;
+
+
+ /**
+ * Creates a new instance of AbstractClauseComposite.
+ */
+ public AbstractClauseComposite()
+ {
+ }
+
+
+ /**
+ * Creates a new instance of AbstractClauseComposite.
+ *
+ * @param clause the clause
+ */
+ public AbstractClauseComposite( C clause, Composite visualEditorComposite )
+ {
+ this.clause = clause;
+ this.visualEditorComposite = visualEditorComposite;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Composite createComposite( Composite parent )
+ {
+ return null;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Composite getVisualEditorComposite()
+ {
+ return visualEditorComposite;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setVisualEditorComposite( Composite visualEditorComposite )
+ {
+ this.visualEditorComposite = visualEditorComposite;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public IBrowserConnection getConnection()
+ {
+ return connection;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setConnection( IBrowserConnection connection )
+ {
+ this.connection = connection;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public C getClause()
+ {
+ return clause;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setClause( C clause )
+ {
+ this.clause = clause;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void saveWidgetSettings()
+ {
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/AbstractWhoClauseCryptoStrengthComposite.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/AbstractWhoClauseCryptoStrengthComposite.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/AbstractWhoClauseCryptoStrengthComposite.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/AbstractWhoClauseCryptoStrengthComposite.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.openldap.config.acl.widgets.composites;
+
+
+import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Spinner;
+
+import org.apache.directory.studio.openldap.config.acl.model.AbstractAclWhoClauseCryptoStrength;
+import org.apache.directory.studio.openldap.config.acl.widgets.AclWhoClauseSsfValuesEnum;
+
+
+public class AbstractWhoClauseCryptoStrengthComposite<C extends AbstractAclWhoClauseCryptoStrength> extends
+ AbstractClauseComposite<C> implements WhoClauseComposite<C>
+{
+ /** The array of SSF who clause values */
+ private static final AclWhoClauseSsfValuesEnum[] aclWhoClauseSsfValues = new AclWhoClauseSsfValuesEnum[]
+ {
+ AclWhoClauseSsfValuesEnum.ANY,
+ AclWhoClauseSsfValuesEnum.FORTY,
+ AclWhoClauseSsfValuesEnum.FIFTY_SIX,
+ AclWhoClauseSsfValuesEnum.SIXTY_FOUR,
+ AclWhoClauseSsfValuesEnum.ONE_TWENTY_HEIGHT,
+ AclWhoClauseSsfValuesEnum.ONE_SIXTY_FOUR,
+ AclWhoClauseSsfValuesEnum.TWO_FIFTY_SIX,
+ AclWhoClauseSsfValuesEnum.CUSTOM
+ };
+
+ /** The SSF values combo viewer */
+ private ComboViewer ssfValuesComboViewer;
+
+ /** The custom SSF value spinner */
+ private Spinner customSsfValueSpinner;
+
+ /** The current SSF value */
+ private AclWhoClauseSsfValuesEnum currentSsfValue;
+
+
+ /**
+ * Creates a new instance of AbstractWhoClauseCryptoStrengthComposite.
+ *
+ * @param clause the clause
+ * @param visualEditorComposite the visual editor composite
+ */
+ public AbstractWhoClauseCryptoStrengthComposite( C clause, Composite visualEditorComposite )
+ {
+ super( clause, visualEditorComposite );
+ }
+
+
+ public Composite createComposite( Composite parent )
+ {
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
+
+ // SSF Value Label
+ BaseWidgetUtils.createLabel( composite, "SSF Value:", 1 );
+
+ // SSF Values Combo Viewer
+ ssfValuesComboViewer = new ComboViewer( BaseWidgetUtils.createReadonlyCombo(
+ composite, new String[0], -1, 1 ) );
+ ssfValuesComboViewer.getCombo().setLayoutData( new GridData( SWT.NONE, SWT.NONE, false, false ) );
+ ssfValuesComboViewer.setContentProvider( new ArrayContentProvider() );
+ ssfValuesComboViewer.setLabelProvider( new LabelProvider()
+ {
+ public String getText( Object element )
+ {
+ if ( element instanceof AclWhoClauseSsfValuesEnum )
+ {
+ AclWhoClauseSsfValuesEnum value = ( AclWhoClauseSsfValuesEnum ) element;
+ switch ( value )
+ {
+ case ANY:
+ return "1 (Any)";
+ case FORTY:
+ return "40";
+ case FIFTY_SIX:
+ return "56";
+ case SIXTY_FOUR:
+ return "64";
+ case ONE_TWENTY_HEIGHT:
+ return "128";
+ case ONE_SIXTY_FOUR:
+ return "164";
+ case TWO_FIFTY_SIX:
+ return "256";
+ case CUSTOM:
+ return "Custom";
+ }
+ }
+
+ return super.getText( element );
+ }
+ } );
+ ssfValuesComboViewer.setInput( aclWhoClauseSsfValues );
+ ssfValuesComboViewer.setSelection( new StructuredSelection( aclWhoClauseSsfValues[0] ) );
+ ssfValuesComboViewer.addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ // Getting the selected who clause
+ AclWhoClauseSsfValuesEnum ssfValue = ( AclWhoClauseSsfValuesEnum ) ( ( StructuredSelection ) ssfValuesComboViewer
+ .getSelection() ).getFirstElement();
+
+ // Only changing the UI when the clause is different
+ if ( currentSsfValue != ssfValue )
+ {
+ // Storing the current value
+ currentSsfValue = ssfValue;
+
+ // Making the spinner hidden/visible (depending on the choice
+ customSsfValueSpinner.setVisible( AclWhoClauseSsfValuesEnum.CUSTOM.equals( currentSsfValue ) );
+
+ // Refreshing the layout of the parent composite
+ visualEditorComposite.layout( true, true );
+ }
+ }
+ } );
+
+ // Custom SSF Value Spinner
+ customSsfValueSpinner = new Spinner( composite, SWT.BORDER );
+ customSsfValueSpinner.setMinimum( 1 );
+ customSsfValueSpinner.setTextLimit( 4 );
+ customSsfValueSpinner.setVisible( false );
+ customSsfValueSpinner.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ System.out.println( customSsfValueSpinner.getSelection() );
+ }
+ } );
+
+ return composite;
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/ClauseComposite.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/ClauseComposite.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/ClauseComposite.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/ClauseComposite.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.openldap.config.acl.widgets.composites;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.eclipse.swt.widgets.Composite;
+
+
+/**
+ * This interface defines a clause composite.
+ */
+public interface ClauseComposite<C>
+{
+ /**
+ * Creates the composite.
+ *
+ * @param parent the parent composite
+ */
+ public Composite createComposite( Composite parent );
+
+
+ /**
+ * Gets the visual editor composite.
+ *
+ * @return the visual editor composite
+ */
+ public Composite getVisualEditorComposite();
+
+
+ /**
+ * Sets the visual editor composite.
+ *
+ * @param visualEditorComposite the visual editor composite
+ */
+ public void setVisualEditorComposite( Composite visualEditorComposite );
+
+
+ /**
+ * Gets the connection.
+ *
+ * @return the connection
+ */
+ public IBrowserConnection getConnection();
+
+
+ /**
+ * Sets the connection.
+ *
+ * @param connection the connection
+ */
+ public void setConnection( IBrowserConnection connection );
+
+
+ /**
+ * Gets the clause.
+ *
+ * @return the clause
+ */
+ public C getClause();
+
+
+ /**
+ * Sets the clause.
+ *
+ * @param clause the clause
+ */
+ public void setClause( C clause );
+
+
+ /**
+ * Saves widget settings.
+ */
+ public void saveWidgetSettings();
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseAttributesComposite.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseAttributesComposite.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseAttributesComposite.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseAttributesComposite.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.openldap.config.acl.widgets.composites;
+
+
+import java.util.Arrays;
+
+import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.eclipse.swt.widgets.Composite;
+
+import org.apache.directory.studio.openldap.config.acl.model.AclWhatClauseAttributes;
+import org.apache.directory.studio.openldap.config.acl.widgets.AttributesWidget;
+
+
+public class WhatClauseAttributesComposite extends AbstractClauseComposite<AclWhatClauseAttributes> implements
+ WhatClauseComposite<AclWhatClauseAttributes>
+{
+ /** The attributes widget */
+ private AttributesWidget attributesWidget;
+
+ /** The modify listener */
+ private WidgetModifyListener modifyListener = new WidgetModifyListener()
+ {
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ getClause().clearAttributes();
+ getClause().addAllAttributes( Arrays.asList( attributesWidget.getAttributes() ) );
+ }
+ };
+
+
+ public WhatClauseAttributesComposite( AclWhatClauseAttributes clause, Composite visualEditorComposite )
+ {
+ super( clause, visualEditorComposite );
+ }
+
+
+ public WhatClauseAttributesComposite( Composite visualEditorComposite )
+ {
+ super( new AclWhatClauseAttributes(), visualEditorComposite );
+ }
+
+
+ public Composite createComposite( Composite parent )
+ {
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 2, 1 );
+
+ BaseWidgetUtils.createLabel( composite, "Attributes:", 1 );
+ attributesWidget = new AttributesWidget();
+ attributesWidget.createWidget( composite );
+ attributesWidget.addWidgetModifyListener( modifyListener );
+
+ return composite;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setClause( AclWhatClauseAttributes clause )
+ {
+ super.setClause( clause );
+ setInput();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setConnection( IBrowserConnection connection )
+ {
+ super.setConnection( connection );
+ setInput();
+ }
+
+
+ private void setInput()
+ {
+ if ( attributesWidget != null )
+ {
+ attributesWidget.setBrowserConnection( connection );
+ if ( clause != null )
+ {
+ attributesWidget.setInitialAttributes( clause.getAttributes().toArray( new String[0] ) );
+ }
+ else
+ {
+ attributesWidget.setInitialAttributes( new String[0] );
+ }
+ }
+ }
+
+
+ /**
+ * Saves widget settings.
+ */
+ public void saveWidgetSettings()
+ {
+ if ( attributesWidget != null )
+ {
+ attributesWidget.saveWidgetSettings();
+ }
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseComposite.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseComposite.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseComposite.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseComposite.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.openldap.config.acl.widgets.composites;
+
+
+/**
+ * This interface defines a clause composite for what clauses.
+ */
+public interface WhatClauseComposite<C> extends ClauseComposite<C>
+{
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseDnComposite.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseDnComposite.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseDnComposite.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseDnComposite.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.openldap.config.acl.widgets.composites;
+
+
+import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.apache.directory.studio.ldapbrowser.common.widgets.search.EntryWidget;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+
+import org.apache.directory.studio.openldap.config.acl.model.AclWhatClauseDn;
+import org.apache.directory.studio.openldap.config.acl.model.AclWhatClauseDnTypeEnum;
+
+
+public class WhatClauseDnComposite extends AbstractClauseComposite<AclWhatClauseDn> implements
+ WhatClauseComposite<AclWhatClauseDn>
+{
+ /** The array of DN what clause types */
+ private static final AclWhatClauseDnTypeEnum[] aclWhatClauseDnTypes = new AclWhatClauseDnTypeEnum[]
+ {
+ AclWhatClauseDnTypeEnum.BASE,
+ AclWhatClauseDnTypeEnum.EXACT,
+ AclWhatClauseDnTypeEnum.ONE,
+ AclWhatClauseDnTypeEnum.SUBTREE,
+ AclWhatClauseDnTypeEnum.CHILDREN,
+ AclWhatClauseDnTypeEnum.REGEX
+ };
+
+ /** The entry widget */
+ private EntryWidget entryWidget;
+
+ /** The modify listener */
+ private WidgetModifyListener modifyListener = new WidgetModifyListener()
+ {
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ getClause().setPattern( entryWidget.getDn().toString() );
+ }
+ };
+
+
+ public WhatClauseDnComposite( AclWhatClauseDn clause, Composite visualEditorComposite )
+ {
+ super( clause, visualEditorComposite );
+ }
+
+
+ public WhatClauseDnComposite( Composite visualEditorComposite )
+ {
+ super( new AclWhatClauseDn(), visualEditorComposite );
+ }
+
+
+ public Composite createComposite( Composite parent )
+ {
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
+
+ // DN
+ BaseWidgetUtils.createLabel( composite, "DN:", 1 );
+ entryWidget = new EntryWidget();
+ entryWidget.createWidget( composite );
+ entryWidget.addWidgetModifyListener( modifyListener );
+
+ // Type
+ BaseWidgetUtils.createLabel( composite, "Type:", 1 );
+ ComboViewer whatClauseDnTypeComboViewer = new ComboViewer( BaseWidgetUtils.createReadonlyCombo( composite,
+ new String[0], -1, 1 ) );
+ whatClauseDnTypeComboViewer.getCombo().setLayoutData( new GridData( SWT.NONE, SWT.NONE, false, false, 2, 1 ) );
+ whatClauseDnTypeComboViewer.setContentProvider( new ArrayContentProvider() );
+ whatClauseDnTypeComboViewer.setLabelProvider( new LabelProvider()
+ {
+ public String getText( Object element )
+ {
+ if ( element instanceof AclWhatClauseDnTypeEnum )
+ {
+ AclWhatClauseDnTypeEnum value = ( AclWhatClauseDnTypeEnum ) element;
+ switch ( value )
+ {
+ case BASE:
+ return "Base";
+ case EXACT:
+ return "Exact";
+ case ONE:
+ return "One";
+ case SUBTREE:
+ return "Subtree";
+ case CHILDREN:
+ return "Children";
+ case REGEX:
+ return "Regex";
+ }
+ }
+
+ return super.getText( element );
+ }
+ } );
+ whatClauseDnTypeComboViewer.setInput( aclWhatClauseDnTypes );
+
+ return composite;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setClause( AclWhatClauseDn clause )
+ {
+ super.setClause( clause );
+ setInput();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setConnection( IBrowserConnection connection )
+ {
+ super.setConnection( connection );
+ setInput();
+ }
+
+
+ private void setInput()
+ {
+ if ( entryWidget != null )
+ {
+ if ( clause != null )
+ {
+ try
+ {
+ entryWidget.setInput( connection, new Dn( clause.getPattern() ) );
+ }
+ catch ( LdapInvalidDnException e )
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ else
+ {
+ entryWidget.setInput( connection, null );
+ }
+ }
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseFilterComposite.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseFilterComposite.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseFilterComposite.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseFilterComposite.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.openldap.config.acl.widgets.composites;
+
+
+import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.apache.directory.studio.ldapbrowser.common.widgets.search.FilterWidget;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.eclipse.swt.widgets.Composite;
+
+import org.apache.directory.studio.openldap.config.acl.model.AclWhatClauseFilter;
+
+
+public class WhatClauseFilterComposite extends AbstractClauseComposite<AclWhatClauseFilter> implements
+ WhatClauseComposite<AclWhatClauseFilter>
+{
+ /** The filter widget */
+ private FilterWidget filterWidget;
+
+ private WidgetModifyListener modifyListener = new WidgetModifyListener()
+ {
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ getClause().setFilter( filterWidget.getFilter() );
+ }
+ };
+
+
+ public WhatClauseFilterComposite( AclWhatClauseFilter clause, Composite visualEditorComposite )
+ {
+ super( clause, visualEditorComposite );
+ }
+
+
+ public WhatClauseFilterComposite( Composite visualEditorComposite )
+ {
+ super( new AclWhatClauseFilter(), visualEditorComposite );
+ }
+
+
+ public Composite createComposite( Composite parent )
+ {
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
+
+ BaseWidgetUtils.createLabel( composite, "Filter:", 1 );
+ filterWidget = new FilterWidget();
+ filterWidget.createWidget( composite );
+ filterWidget.addWidgetModifyListener( modifyListener );
+
+ return composite;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setClause( AclWhatClauseFilter clause )
+ {
+ super.setClause( clause );
+ setInput();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setConnection( IBrowserConnection connection )
+ {
+ super.setConnection( connection );
+ setInput();
+ }
+
+
+ private void setInput()
+ {
+ if ( filterWidget != null )
+ {
+ filterWidget.setBrowserConnection( connection );
+ if ( clause != null )
+ {
+ String filter = clause.getFilter();
+ filterWidget.setFilter( ( filter != null ) ? filter : "" );
+ }
+ else
+ {
+ filterWidget.setFilter( "" );
+ }
+ }
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseStarComposite.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseStarComposite.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseStarComposite.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseStarComposite.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.openldap.config.acl.widgets.composites;
+
+
+import org.eclipse.swt.widgets.Composite;
+
+import org.apache.directory.studio.openldap.config.acl.model.AclWhatClauseStar;
+
+
+public class WhatClauseStarComposite extends AbstractClauseComposite<AclWhatClauseStar> implements
+ WhatClauseComposite<AclWhatClauseStar>
+{
+ public WhatClauseStarComposite( AclWhatClauseStar clause, Composite visualEditorComposite )
+ {
+ super( clause, visualEditorComposite );
+ }
+
+
+ public WhatClauseStarComposite( Composite visualEditorComposite )
+ {
+ super( new AclWhatClauseStar(), visualEditorComposite );
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseAnonymousComposite.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseAnonymousComposite.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseAnonymousComposite.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseAnonymousComposite.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.openldap.config.acl.widgets.composites;
+
+
+import org.eclipse.swt.widgets.Composite;
+
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseAnonymous;
+
+
+public class WhoClauseAnonymousComposite extends AbstractClauseComposite<AclWhoClauseAnonymous> implements
+ WhoClauseComposite<AclWhoClauseAnonymous>
+{
+ public WhoClauseAnonymousComposite( AclWhoClauseAnonymous clause, Composite visualEditorComposite )
+ {
+ super( clause, visualEditorComposite );
+ }
+
+
+ public WhoClauseAnonymousComposite( Composite visualEditorComposite )
+ {
+ super( new AclWhoClauseAnonymous(), visualEditorComposite );
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseComposite.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseComposite.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseComposite.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseComposite.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.openldap.config.acl.widgets.composites;
+
+
+import org.apache.directory.studio.openldap.config.acl.model.AclWhoClause;
+
+
+/**
+ * This interface defines a clause composite for who clauses.
+ */
+public interface WhoClauseComposite<C extends AclWhoClause> extends ClauseComposite<C>
+{
+}