Author: seelmann Date: Sun Apr 1 13:35:23 2007 New Revision: 524677 URL: http://svn.apache.org/viewvc?view=rev&rev=524677 Log: Added two more value editors, integrated all into the ACIItemValueEditor Added: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/MaxValueCountValueEditor.java directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/RestrictedByValueEditor.java Modified: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/MultiValuedDialog.java directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/ProtectedItemWrapperFactory.java directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemSourceEditorComposite.java directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserClassesComposite.java Added: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/MaxValueCountValueEditor.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/MaxValueCountValueEditor.java?view=auto&rev=524677 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/MaxValueCountValueEditor.java (added) +++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/MaxValueCountValueEditor.java Sun Apr 1 13:35:23 2007 @@ -0,0 +1,382 @@ +/* + * 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.ldapstudio.aciitemeditor; + + +import java.util.Arrays; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy; +import org.apache.directory.ldapstudio.browser.core.model.IConnection; +import org.apache.directory.ldapstudio.browser.core.model.IValue; +import org.apache.directory.ldapstudio.browser.core.model.schema.Schema; +import org.apache.directory.ldapstudio.browser.ui.dialogs.TextDialog; +import org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogStringValueEditor; +import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils; +import org.apache.directory.ldapstudio.browser.ui.widgets.ListContentProposalProvider; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.fieldassist.ComboContentAdapter; +import org.eclipse.jface.fieldassist.ContentProposalAdapter; +import org.eclipse.jface.fieldassist.DecoratedField; +import org.eclipse.jface.fieldassist.FieldDecoration; +import org.eclipse.jface.fieldassist.FieldDecorationRegistry; +import org.eclipse.jface.fieldassist.IControlCreator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Spinner; + + +/** + * ACI item editor specific value editor to edit the MaxValueCount protected item. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class MaxValueCountValueEditor extends AbstractDialogStringValueEditor +{ + + /** + * {@inheritDoc} + * + * This implementation opens the MaxValueCountDialog. + */ + public boolean openDialog( Shell shell ) + { + Object value = getValue(); + if ( value != null && value instanceof MaxValueCountValueEditorRawValueWrapper ) + { + MaxValueCountValueEditorRawValueWrapper wrapper = ( MaxValueCountValueEditorRawValueWrapper ) value; + MaxValueCountDialog dialog = new MaxValueCountDialog( shell, wrapper.schema, wrapper.type, wrapper.maxCount ); + if ( dialog.open() == TextDialog.OK && !"".equals( dialog.getType() ) && dialog.getMaxCount() > -1 ) + { + setValue( "{ type " + dialog.getType() + ", maxCount " + dialog.getMaxCount() + " }" ); + return true; + } + } + return false; + } + + + /** + * {@inheritDoc} + * + * Returns always the string value. + * + * Reimplementation, because getRawValue() returns an + * MaxValueCountValueEditorRawValueWrapper. + */ + public String getDisplayValue( IValue value ) + { + if ( value == null ) + { + return "NULL"; + } + + String displayValue = value.getStringValue(); + return displayValue; + } + + + /** + * {@inheritDoc} + * + * Returns null. + * Modification in search result editor not supported. + */ + public Object getRawValue( AttributeHierarchy attributeHierarchy ) + { + return null; + } + + + /** + * {@inheritDoc} + * + * Returns an MaxValueCountValueEditorRawValueWrapper. + */ + public Object getRawValue( IValue value ) + { + if ( value == null || !value.isString() ) + { + return null; + } + else + { + return getRawValue( value.getAttribute().getEntry().getConnection(), value.getStringValue() ); + } + } + + + /** + * {@inheritDoc} + * + * Returns an MaxValueCountValueEditorRawValueWrapper. + */ + public Object getRawValue( IConnection connection, Object value ) + { + Schema schema = null; + if ( connection != null ) + { + schema = connection.getSchema(); + } + if ( schema == null || value == null || !( value instanceof String ) ) + { + return null; + } + + String stringValue = ( String ) value; + String type = ""; + int maxCount = 0; + try + { + // for example: { type userPassword, maxCount 10 } + Pattern pattern = Pattern.compile("\\s*\\{\\s*type\\s*([^,]*),\\s*maxCount\\s*(\\d*)\\s*\\}\\s*"); + Matcher matcher = pattern.matcher(stringValue); + type = matcher.matches() ? matcher.group(1) : ""; + maxCount = matcher.matches() ? Integer.valueOf( matcher.group(2) ) : 0; + } + catch(Exception e) + { + } + + MaxValueCountValueEditorRawValueWrapper wrapper = new MaxValueCountValueEditorRawValueWrapper( schema, type, maxCount ); + return wrapper; + } + + /** + * The MaxValueCountValueEditorRawValueWrapper is used to pass contextual + * information to the opened MaxValueCountDialog. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ + private class MaxValueCountValueEditorRawValueWrapper + { + /** + * The schema, used in MaxValueCountDialog to build the list + * with possible attribute types. + */ + private Schema schema; + + /** The attribute type, used as initial attribute type. */ + private String type; + + /** The max count, used as initial value. */ + private int maxCount; + + + /** + * Creates a new instance of AttributeTypeAndValueValueEditorRawValueWrapper. + * + * @param schema the schema + * @param attributeType the attribute type + * @param value the value + */ + private MaxValueCountValueEditorRawValueWrapper( Schema schema, String type, int maxCount ) + { + this.schema = schema; + this.type = type; + this.maxCount = maxCount; + } + } + + + /** + * This class provides a dialog to enter the MaxValueCount values. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ + private class MaxValueCountDialog extends Dialog + { + + /** The dialog title */ + public static final String DIALOG_TITLE = "Max Value Count Editor"; + + /** The schema. */ + private Schema schema; + + /** The initial attribute type. */ + private String initialType; + + /** The initial max count. */ + private int initialMaxCount; + + /** The attribute type combo field. */ + private DecoratedField attributeTypeComboField; + + /** The attribute type combo. */ + private Combo attributeTypeCombo; + + /** The attribute type content proposal adapter */ + private ContentProposalAdapter attributeTypeCPA; + + /** The max count spinner. */ + private Spinner maxCountSpinner; + + /** The return attribute type. */ + private String returnType; + + /** The return value. */ + private int returnMaxCount; + + + /** + * Creates a new instance of AttributeTypeDialog. + * + * @param parentShell the parent shell + * @param schema the schema + * @param initialType the initial attribute type + * @param initialMaxCount the initial max count + */ + public MaxValueCountDialog( Shell parentShell, Schema schema, String initialType, + int initialMaxCount ) + { + super( parentShell ); + super.setShellStyle( super.getShellStyle() | SWT.RESIZE ); + this.initialType = initialType; + this.initialMaxCount = initialMaxCount; + this.schema = schema; + this.returnType = null; + this.returnMaxCount = -1; + } + + + /** + * {@inheritDoc} + */ + protected void configureShell( Shell shell ) + { + super.configureShell( shell ); + shell.setText( DIALOG_TITLE ); + } + + + /** + * {@inheritDoc} + */ + protected void createButtonsForButtonBar( Composite parent ) + { + super.createButtonsForButtonBar( parent ); + } + + + /** + * {@inheritDoc} + */ + protected void okPressed() + { + returnType = attributeTypeCombo.getText(); + returnMaxCount = maxCountSpinner.getSelection(); + super.okPressed(); + } + + + /** + * {@inheritDoc} + */ + protected Control createDialogArea( Composite parent ) + { + // create composite + Composite composite = ( Composite ) super.createDialogArea( parent ); + GridData gd = new GridData( GridData.FILL_BOTH ); + gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ); + composite.setLayoutData( gd ); + composite.setLayout( new GridLayout( 5, false ) ); + + BaseWidgetUtils.createLabel( composite, "{ type ", 1 ); + + // combo widget + String[] allAtNames = schema.getAttributeTypeDescriptionNames(); + Arrays.sort( allAtNames ); + + final FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration( + FieldDecorationRegistry.DEC_CONTENT_PROPOSAL ); + attributeTypeComboField = new DecoratedField( composite, SWT.NONE, new IControlCreator() + { + public Control createControl( Composite parent, int style ) + { + Combo combo = BaseWidgetUtils.createCombo( parent, new String[0], -1, 1 ); + combo.setVisibleItemCount( 20 ); + return combo; + } + } ); + attributeTypeComboField.addFieldDecoration( fieldDecoration, SWT.TOP | SWT.LEFT, true ); + attributeTypeComboField.getLayoutControl().setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) ); + attributeTypeCombo = ( Combo ) attributeTypeComboField.getControl(); + attributeTypeCombo.setItems( allAtNames ); + attributeTypeCombo.setText( initialType ); + + // content proposal adapter + attributeTypeCPA = new ContentProposalAdapter( attributeTypeCombo, new ComboContentAdapter(), + new ListContentProposalProvider( attributeTypeCombo.getItems() ), null, null ); + attributeTypeCPA.setFilterStyle( ContentProposalAdapter.FILTER_NONE ); + attributeTypeCPA.setProposalAcceptanceStyle( ContentProposalAdapter.PROPOSAL_REPLACE ); + + BaseWidgetUtils.createLabel( composite, ", maxCount ", 1 ); + + maxCountSpinner = new Spinner( composite, SWT.BORDER ); + maxCountSpinner.setMinimum( 0 ); + maxCountSpinner.setMaximum( Integer.MAX_VALUE ); + maxCountSpinner.setDigits( 0 ); + maxCountSpinner.setIncrement( 1 ); + maxCountSpinner.setPageIncrement( 100 ); + maxCountSpinner.setSelection( initialMaxCount ); + maxCountSpinner.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); + + BaseWidgetUtils.createLabel( composite, " }", 1 ); + + applyDialogFont( composite ); + return composite; + } + + + /** + * Gets the attribute type. + * + * @return the attribute type, null if canceled + */ + public String getType() + { + return returnType; + } + + + /** + * Gets the max count. + * + * @return the max count, -1 if canceled + */ + public int getMaxCount() + { + return returnMaxCount; + } + + } + +} Added: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/RestrictedByValueEditor.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/RestrictedByValueEditor.java?view=auto&rev=524677 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/RestrictedByValueEditor.java (added) +++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/RestrictedByValueEditor.java Sun Apr 1 13:35:23 2007 @@ -0,0 +1,400 @@ +/* + * 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.ldapstudio.aciitemeditor; + + +import java.util.Arrays; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy; +import org.apache.directory.ldapstudio.browser.core.model.IConnection; +import org.apache.directory.ldapstudio.browser.core.model.IValue; +import org.apache.directory.ldapstudio.browser.core.model.schema.Schema; +import org.apache.directory.ldapstudio.browser.ui.dialogs.TextDialog; +import org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogStringValueEditor; +import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils; +import org.apache.directory.ldapstudio.browser.ui.widgets.ListContentProposalProvider; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.fieldassist.ComboContentAdapter; +import org.eclipse.jface.fieldassist.ContentProposalAdapter; +import org.eclipse.jface.fieldassist.DecoratedField; +import org.eclipse.jface.fieldassist.FieldDecoration; +import org.eclipse.jface.fieldassist.FieldDecorationRegistry; +import org.eclipse.jface.fieldassist.IControlCreator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + + +/** + * ACI item editor specific value editor to edit the RestrictedBy protected item. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class RestrictedByValueEditor extends AbstractDialogStringValueEditor +{ + + /** + * {@inheritDoc} + * + * This implementation opens the RestrictedByDialog. + */ + public boolean openDialog( Shell shell ) + { + Object value = getValue(); + if ( value != null && value instanceof RestrictedByValueEditorRawValueWrapper ) + { + RestrictedByValueEditorRawValueWrapper wrapper = ( RestrictedByValueEditorRawValueWrapper ) value; + RestrictedByDialog dialog = new RestrictedByDialog( shell, wrapper.schema, wrapper.type, wrapper.valuesIn ); + if ( dialog.open() == TextDialog.OK && !"".equals( dialog.getType() ) && !"".equals( dialog.getValuesIn() ) ) + { + setValue( "{ type " + dialog.getType() + ", valuesIn " + dialog.getValuesIn() + " }" ); + return true; + } + } + return false; + } + + + /** + * {@inheritDoc} + * + * Returns always the string value. + * + * Reimplementation, because getRawValue() returns an + * RestrictedByValueEditorRawValueWrapper. + */ + public String getDisplayValue( IValue value ) + { + if ( value == null ) + { + return "NULL"; + } + + String displayValue = value.getStringValue(); + return displayValue; + } + + + /** + * {@inheritDoc} + * + * Returns null. + * Modification in search result editor not supported. + */ + public Object getRawValue( AttributeHierarchy attributeHierarchy ) + { + return null; + } + + + /** + * {@inheritDoc} + * + * Returns an RestrictedByValueEditorRawValueWrapper. + */ + public Object getRawValue( IValue value ) + { + if ( value == null || !value.isString() ) + { + return null; + } + else + { + return getRawValue( value.getAttribute().getEntry().getConnection(), value.getStringValue() ); + } + } + + + /** + * {@inheritDoc} + * + * Returns an RestrictedByValueEditorRawValueWrapper. + */ + public Object getRawValue( IConnection connection, Object value ) + { + Schema schema = null; + if ( connection != null ) + { + schema = connection.getSchema(); + } + if ( schema == null || value == null || !( value instanceof String ) ) + { + return null; + } + + String stringValue = ( String ) value; + String type = ""; + String valuesIn = ""; + try + { + // for example: { type sn, valuesIn cn } + Pattern pattern = Pattern.compile( "\\s*\\{\\s*type\\s*([^,\\s]*)\\s*,\\s*valuesIn\\s*([^,\\s]*)\\s*\\}\\s*" ); + Matcher matcher = pattern.matcher( stringValue ); + type = matcher.matches() ? matcher.group( 1 ) : ""; + valuesIn = matcher.matches() ? matcher.group( 2 ) : ""; + } + catch ( Throwable e ) + { + e.printStackTrace(); + } + + RestrictedByValueEditorRawValueWrapper wrapper = new RestrictedByValueEditorRawValueWrapper( schema, type, + valuesIn ); + return wrapper; + } + + /** + * The RestrictedByValueEditorRawValueWrapper is used to pass contextual + * information to the opened RestrictedByDialog. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ + private class RestrictedByValueEditorRawValueWrapper + { + /** + * The schema, used in RestrictedByDialog to build the list + * with possible attribute types. + */ + private Schema schema; + + /** The type, used as initial type. */ + private String type; + + /** The values in, used as initial values in. */ + private String valuesIn; + + + /** + * Creates a new instance of RestrictedByValueEditorRawValueWrapper. + * + * @param schema the schema + * @param type the type + * @param valuesIn the values in + */ + private RestrictedByValueEditorRawValueWrapper( Schema schema, String type, String valuesIn ) + { + this.schema = schema; + this.type = type; + this.valuesIn = valuesIn; + } + } + + /** + * This class provides a dialog to enter the RestrictedBy values. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ + private class RestrictedByDialog extends Dialog + { + + /** The dialog title */ + public static final String DIALOG_TITLE = "Restricted By Editor"; + + /** The schema. */ + private Schema schema; + + /** The initial type. */ + private String initialType; + + /** The initial values in. */ + private String initialValuesIn; + + /** The type combo field. */ + private DecoratedField typeComboField; + + /** The type combo. */ + private Combo typeCombo; + + /** The type content proposal adapter */ + private ContentProposalAdapter typeCPA; + + /** The values in combo field. */ + private DecoratedField valuesInComboField; + + /** The values in combo. */ + private Combo valuesInCombo; + + /** The values in content proposal adapter */ + private ContentProposalAdapter valuesInCPA; + + /** The return type. */ + private String returnType; + + /** The return values in. */ + private String returnValuesIn; + + + /** + * Creates a new instance of RestrictedByDialog. + * + * @param parentShell the parent shell + * @param schema the schema + * @param initialType the initial type + * @param initialValuesIn the initial values in + */ + public RestrictedByDialog( Shell parentShell, Schema schema, String initialType, String initialValuesIn ) + { + super( parentShell ); + super.setShellStyle( super.getShellStyle() | SWT.RESIZE ); + this.initialType = initialType; + this.initialValuesIn = initialValuesIn; + this.schema = schema; + this.returnType = null; + this.returnValuesIn = null; + } + + + /** + * {@inheritDoc} + */ + protected void configureShell( Shell shell ) + { + super.configureShell( shell ); + shell.setText( DIALOG_TITLE ); + } + + + /** + * {@inheritDoc} + */ + protected void createButtonsForButtonBar( Composite parent ) + { + super.createButtonsForButtonBar( parent ); + } + + + /** + * {@inheritDoc} + */ + protected void okPressed() + { + returnType = typeCombo.getText(); + returnValuesIn = valuesInCombo.getText(); + super.okPressed(); + } + + + /** + * {@inheritDoc} + */ + protected Control createDialogArea( Composite parent ) + { + // create composite + Composite composite = ( Composite ) super.createDialogArea( parent ); + GridData gd = new GridData( GridData.FILL_BOTH ); + gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ); + composite.setLayoutData( gd ); + composite.setLayout( new GridLayout( 5, false ) ); + + BaseWidgetUtils.createLabel( composite, "{ type ", 1 ); + + // combo widget + String[] allAtNames = schema.getAttributeTypeDescriptionNames(); + Arrays.sort( allAtNames ); + + final FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration( + FieldDecorationRegistry.DEC_CONTENT_PROPOSAL ); + + typeComboField = new DecoratedField( composite, SWT.NONE, new IControlCreator() + { + public Control createControl( Composite parent, int style ) + { + Combo combo = BaseWidgetUtils.createCombo( parent, new String[0], -1, 1 ); + combo.setVisibleItemCount( 20 ); + return combo; + } + } ); + typeComboField.addFieldDecoration( fieldDecoration, SWT.TOP | SWT.LEFT, true ); + typeComboField.getLayoutControl().setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) ); + typeCombo = ( Combo ) typeComboField.getControl(); + typeCombo.setItems( allAtNames ); + typeCombo.setText( initialType ); + + // content proposal adapter + typeCPA = new ContentProposalAdapter( typeCombo, new ComboContentAdapter(), + new ListContentProposalProvider( typeCombo.getItems() ), null, null ); + typeCPA.setFilterStyle( ContentProposalAdapter.FILTER_NONE ); + typeCPA.setProposalAcceptanceStyle( ContentProposalAdapter.PROPOSAL_REPLACE ); + + BaseWidgetUtils.createLabel( composite, ", valuesIn ", 1 ); + + valuesInComboField = new DecoratedField( composite, SWT.NONE, new IControlCreator() + { + public Control createControl( Composite parent, int style ) + { + Combo combo = BaseWidgetUtils.createCombo( parent, new String[0], -1, 1 ); + combo.setVisibleItemCount( 20 ); + return combo; + } + } ); + valuesInComboField.addFieldDecoration( fieldDecoration, SWT.TOP | SWT.LEFT, true ); + valuesInComboField.getLayoutControl().setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) ); + valuesInCombo = ( Combo ) valuesInComboField.getControl(); + valuesInCombo.setItems( allAtNames ); + valuesInCombo.setText( initialValuesIn ); + + // content proposal adapter + valuesInCPA = new ContentProposalAdapter( valuesInCombo, new ComboContentAdapter(), + new ListContentProposalProvider( valuesInCombo.getItems() ), null, null ); + valuesInCPA.setFilterStyle( ContentProposalAdapter.FILTER_NONE ); + valuesInCPA.setProposalAcceptanceStyle( ContentProposalAdapter.PROPOSAL_REPLACE ); + + BaseWidgetUtils.createLabel( composite, " }", 1 ); + + applyDialogFont( composite ); + return composite; + } + + + /** + * Gets the type. + * + * @return the type, null if canceled + */ + public String getType() + { + return returnType; + } + + + /** + * Gets the values in. + * + * @return the values in, null if canceled + */ + public String getValuesIn() + { + return returnValuesIn; + } + + } + +} Modified: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/MultiValuedDialog.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/MultiValuedDialog.java?view=diff&rev=524677&r1=524676&r2=524677 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/MultiValuedDialog.java (original) +++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/MultiValuedDialog.java Sun Apr 1 13:35:23 2007 @@ -119,7 +119,7 @@ protected void configureShell( Shell shell ) { super.configureShell( shell ); - shell.setText( "Edit " + displayName + " Values" ); + shell.setText( "Edit " + displayName ); } Modified: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/ProtectedItemWrapperFactory.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/ProtectedItemWrapperFactory.java?view=diff&rev=524677&r1=524676&r2=524677 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/ProtectedItemWrapperFactory.java (original) +++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/ProtectedItemWrapperFactory.java Sun Apr 1 13:35:23 2007 @@ -1,6 +1,12 @@ package org.apache.directory.ldapstudio.aciitemeditor.model; +import org.apache.directory.ldapstudio.aciitemeditor.MaxValueCountValueEditor; +import org.apache.directory.ldapstudio.aciitemeditor.RestrictedByValueEditor; +import org.apache.directory.ldapstudio.browser.ui.valueeditors.internal.AttributeTypeAndValueValueEditor; +import org.apache.directory.ldapstudio.browser.ui.valueeditors.internal.AttributeTypeValueEditor; +import org.apache.directory.ldapstudio.browser.ui.valueeditors.internal.FilterValueEditor; +import org.apache.directory.ldapstudio.browser.ui.valueeditors.internal.IntegerValueEditor; import org.apache.directory.ldapstudio.browser.ui.valueeditors.internal.TextValueEditor; import org.apache.directory.shared.ldap.aci.ProtectedItem; @@ -38,7 +44,7 @@ true, "", //$NON-NLS-1$ "", //$NON-NLS-1$ - new TextValueEditor() // TODO: AttributeTypeValueEditor + new AttributeTypeValueEditor() ), // allAttributeValues { 1.2.3, cn } @@ -48,7 +54,7 @@ true, "", //$NON-NLS-1$ "", //$NON-NLS-1$ - new TextValueEditor() // TODO: AttributeTypeValueEditor + new AttributeTypeValueEditor() ), // attributeType @@ -68,7 +74,7 @@ true, "", //$NON-NLS-1$ "", //$NON-NLS-1$ - new TextValueEditor() // TODO: AttributeTypeAndValueValueEditor + new AttributeTypeAndValueValueEditor() ), // selfValue { 1.2.3, cn } @@ -78,7 +84,7 @@ true, "", //$NON-NLS-1$ "", //$NON-NLS-1$ - new TextValueEditor() // TODO: AttributeTypeValueEditor + new AttributeTypeValueEditor() ), // rangeOfValues (cn=E*) @@ -88,7 +94,7 @@ false, "", //$NON-NLS-1$ "", //$NON-NLS-1$ - new TextValueEditor() + new FilterValueEditor() ), // maxValueCount { { type 10.11.12, maxCount 10 }, { maxCount 20, type 11.12.13 } } @@ -98,7 +104,7 @@ true, "", //$NON-NLS-1$ "", //$NON-NLS-1$ - new TextValueEditor() // TODO: MaxValueCountValueEditor + new MaxValueCountValueEditor() ), // maxImmSub 3 @@ -108,7 +114,7 @@ false, "", //$NON-NLS-1$ "", //$NON-NLS-1$ - new TextValueEditor() // TODO: IntegerValueEditor + new IntegerValueEditor() ), // restrictedBy { { type 10.11.12, valuesIn ou }, { valuesIn cn, type 11.12.13 } } @@ -118,7 +124,7 @@ true, "", //$NON-NLS-1$ "", //$NON-NLS-1$ - new TextValueEditor() // TODO: RestrictedByValueEditor + new RestrictedByValueEditor() ), // classes and : { item: xyz , or:{item:X,item:Y} } Modified: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemSourceEditorComposite.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemSourceEditorComposite.java?view=diff&rev=524677&r1=524676&r2=524677 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemSourceEditorComposite.java (original) +++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemSourceEditorComposite.java Sun Apr 1 13:35:23 2007 @@ -26,7 +26,6 @@ import org.apache.directory.ldapstudio.aciitemeditor.Activator; import org.apache.directory.shared.ldap.aci.ACIItem; import org.apache.directory.shared.ldap.aci.ACIItemParser; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; @@ -35,13 +34,8 @@ import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.text.source.SourceViewerConfiguration; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; @@ -143,6 +137,10 @@ public String getInput() throws ParseException { String input = forceGetInput(); + + // strip new lines + input = input.replaceAll( "\\n", " " ); + input = input.replaceAll( "\\r", " " ); ACIItemParser parser = Activator.getDefault().getACIItemParser(); ACIItem aciItem = parser.parse( input ); Modified: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserClassesComposite.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserClassesComposite.java?view=diff&rev=524677&r1=524676&r2=524677 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserClassesComposite.java (original) +++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserClassesComposite.java Sun Apr 1 13:35:23 2007 @@ -29,8 +29,8 @@ import org.apache.directory.ldapstudio.aciitemeditor.ACIItemValueWithContext; import org.apache.directory.ldapstudio.aciitemeditor.Activator; import org.apache.directory.ldapstudio.aciitemeditor.dialogs.MultiValuedDialog; -import org.apache.directory.ldapstudio.aciitemeditor.model.UserClassWrapperFactory; import org.apache.directory.ldapstudio.aciitemeditor.model.UserClassWrapper; +import org.apache.directory.ldapstudio.aciitemeditor.model.UserClassWrapperFactory; import org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogStringValueEditor; import org.apache.directory.shared.ldap.aci.ProtectedItem; import org.apache.directory.shared.ldap.aci.UserClass;