You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2007/11/05 15:28:02 UTC
svn commit: r592011 [3/6] - in
/directory/sandbox/felixk/studio-aciitemeditor: ./ META-INF/ src/ src/main/
src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/directory/
src/main/java/org/apache/directory/studio/ src/ma...
Added: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/sourceeditor/package-info.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/sourceeditor/package-info.java?rev=592011&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/sourceeditor/package-info.java (added)
+++ directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/sourceeditor/package-info.java Mon Nov 5 06:27:47 2007
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ *
+ */
+/**
+ * Contains the source editor configuration.
+ */
+package org.apache.directory.studio.aciitemeditor.sourceeditor;
\ No newline at end of file
Propchange: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/sourceeditor/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeAndValueDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeAndValueDialog.java?rev=592011&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeAndValueDialog.java (added)
+++ directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeAndValueDialog.java Mon Nov 5 06:27:47 2007
@@ -0,0 +1,204 @@
+/*
+ * 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.aciitemeditor.valueeditors;
+
+
+import java.util.Arrays;
+
+import org.apache.directory.studio.aciitemeditor.Activator;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.ListContentProposalProvider;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
+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.Text;
+
+
+/**
+ * This class provides a dialog to enter an attribute type and value.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeTypeAndValueDialog extends Dialog
+{
+
+ /** The schema. */
+ private Schema schema;
+
+ /** The initial attribute type. */
+ private String initialAttributeType;
+
+ /** The initial value. */
+ private String initialValue;
+
+ /** 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 value text. */
+ private Text valueText;
+
+ /** The return attribute type. */
+ private String returnAttributeType;
+
+ /** The return value. */
+ private String returnValue;
+
+
+ /**
+ * Creates a new instance of AttributeTypeDialog.
+ *
+ * @param parentShell the parent shell
+ * @param schema the schema
+ * @param initialAttributeType the initial attribute type
+ * @param initialValue the initial value
+ */
+ public AttributeTypeAndValueDialog( Shell parentShell, Schema schema, String initialAttributeType,
+ String initialValue )
+ {
+ super( parentShell );
+ super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+ this.initialAttributeType = initialAttributeType;
+ this.initialValue = initialValue;
+ this.schema = schema;
+ this.returnValue = null;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void configureShell( Shell shell )
+ {
+ super.configureShell( shell );
+ shell.setText( Messages.getString("AttributeTypeAndValueDialog.title") ); //$NON-NLS-1$
+ shell.setImage( Activator.getDefault().getImage( Messages.getString("AttributeTypeAndValueDialog.icon") ) ); //$NON-NLS-1$
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void createButtonsForButtonBar( Composite parent )
+ {
+ super.createButtonsForButtonBar( parent );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void okPressed()
+ {
+ returnAttributeType = attributeTypeCombo.getText();
+ returnValue = valueText.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( 3, false ) );
+
+ // 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( initialAttributeType );
+
+ // 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, " = ", 1 ); //$NON-NLS-1$
+
+ valueText = BaseWidgetUtils.createText( composite, initialValue, 1 );
+
+ applyDialogFont( composite );
+ return composite;
+ }
+
+
+ /**
+ * Gets the attribute type.
+ *
+ * @return the attribute type, null if canceled
+ */
+ public String getAttributeType()
+ {
+ return returnAttributeType;
+ }
+
+
+ /**
+ * Gets the value.
+ *
+ * @return the value, null if canceled
+ */
+ public String getValue()
+ {
+ return returnValue;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeAndValueDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeAndValueValueEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeAndValueValueEditor.java?rev=592011&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeAndValueValueEditor.java (added)
+++ directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeAndValueValueEditor.java Mon Nov 5 06:27:47 2007
@@ -0,0 +1,139 @@
+/*
+ * 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.aciitemeditor.valueeditors;
+
+
+import org.apache.directory.studio.ldapbrowser.common.dialogs.TextDialog;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
+import org.apache.directory.studio.valueeditors.AbstractDialogStringValueEditor;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Implementation of IValueEditor for attribute type and value.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeTypeAndValueValueEditor extends AbstractDialogStringValueEditor
+{
+
+ private static final String EMPTY = ""; //$NON-NLS-1$
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * This implementation opens the AttributeTypeDialog.
+ */
+ public boolean openDialog( Shell shell )
+ {
+ Object value = getValue();
+ if ( value != null && value instanceof AttributeTypeAndValueValueEditorRawValueWrapper )
+ {
+ AttributeTypeAndValueValueEditorRawValueWrapper wrapper = ( AttributeTypeAndValueValueEditorRawValueWrapper ) value;
+ AttributeTypeAndValueDialog dialog = new AttributeTypeAndValueDialog( shell, wrapper.schema,
+ wrapper.attributeType, wrapper.value );
+ if ( dialog.open() == TextDialog.OK && !EMPTY.equals( dialog.getAttributeType() )
+ && !EMPTY.equals( dialog.getValue() ) )
+ {
+ setValue( dialog.getAttributeType() + '=' + dialog.getValue() );
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * Returns an AttributeTypeAndValueValueEditorRawValueWrapper.
+ */
+ public Object getRawValue( IValue value )
+ {
+ return value != null ? getRawValue( value.getAttribute().getEntry().getBrowserConnection(), value.getStringValue() )
+ : null;
+ }
+
+
+ private Object getRawValue( IBrowserConnection connection, Object value )
+ {
+ Schema schema = null;
+ if ( connection != null )
+ {
+ schema = connection.getSchema();
+ }
+ if ( schema == null || value == null || !( value instanceof String ) )
+ {
+ return null;
+ }
+
+ String atavValue = ( String ) value;
+ String[] atav = atavValue.split( "=", 2 ); //$NON-NLS-1$
+ String at = atav.length > 0 ? atav[0] : EMPTY;
+ String v = atav.length > 1 ? atav[1] : EMPTY;
+ AttributeTypeAndValueValueEditorRawValueWrapper wrapper = new AttributeTypeAndValueValueEditorRawValueWrapper(
+ schema, at, v );
+ return wrapper;
+ }
+
+ /**
+ * The AttributeTypeAndValueValueEditorRawValueWrapper is used to pass contextual
+ * information to the opened AttributeTypeAndValueDialog.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ private class AttributeTypeAndValueValueEditorRawValueWrapper
+ {
+ /**
+ * The schema, used in AttributeTypeDialog to build the list
+ * with possible attribute types.
+ */
+ private Schema schema;
+
+ /** The attribute type, used as initial attribute type. */
+ private String attributeType;
+
+ /** The value, used as initial value. */
+ private String value;
+
+
+ /**
+ * Creates a new instance of AttributeTypeAndValueValueEditorRawValueWrapper.
+ *
+ * @param schema the schema
+ * @param attributeType the attribute type
+ * @param value the value
+ */
+ private AttributeTypeAndValueValueEditorRawValueWrapper( Schema schema, String attributeType, String value )
+ {
+ super();
+ this.schema = schema;
+ this.attributeType = attributeType;
+ this.value = value;
+ }
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeAndValueValueEditor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeDialog.java?rev=592011&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeDialog.java (added)
+++ directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeDialog.java Mon Nov 5 06:27:47 2007
@@ -0,0 +1,173 @@
+/*
+ * 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.aciitemeditor.valueeditors;
+
+
+import java.util.Arrays;
+
+import org.apache.directory.studio.aciitemeditor.Activator;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.ListContentProposalProvider;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
+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.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * This class provides a dialog to enter or select an attribute type.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeTypeDialog extends Dialog
+{
+
+ /** The schema. */
+ private Schema schema;
+
+ /** The initial value. */
+ private String initialValue;
+
+ /** 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 return value. */
+ private String returnValue;
+
+
+ /**
+ * Creates a new instance of AttributeTypeDialog.
+ *
+ * @param parentShell the parent shell
+ * @param schema the schema
+ * @param initialValue the initial value
+ */
+ public AttributeTypeDialog( Shell parentShell, Schema schema, String initialValue )
+ {
+ super( parentShell );
+ super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+ this.initialValue = initialValue;
+ this.schema = schema;
+ this.returnValue = null;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void configureShell( Shell shell )
+ {
+ super.configureShell( shell );
+ shell.setText( Messages.getString("AttributeTypeDialog.title") ); //$NON-NLS-1$
+ shell.setImage( Activator.getDefault().getImage( Messages.getString("AttributeTypeDialog.icon") ) ); //$NON-NLS-1$
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void createButtonsForButtonBar( Composite parent )
+ {
+ super.createButtonsForButtonBar( parent );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void okPressed()
+ {
+ returnValue = attributeTypeCombo.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 );
+
+ // 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( initialValue );
+
+ // 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 );
+
+ applyDialogFont( composite );
+ return composite;
+ }
+
+
+ /**
+ * Gets the attribute type.
+ *
+ * @return the attribute type, null if canceled
+ */
+ public String getAttributeType()
+ {
+ return returnValue;
+ }
+}
Propchange: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeValueEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeValueEditor.java?rev=592011&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeValueEditor.java (added)
+++ directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeValueEditor.java Mon Nov 5 06:27:47 2007
@@ -0,0 +1,128 @@
+/*
+ * 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.aciitemeditor.valueeditors;
+
+
+import org.apache.directory.studio.ldapbrowser.common.dialogs.TextDialog;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
+import org.apache.directory.studio.valueeditors.AbstractDialogStringValueEditor;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Implementation of IValueEditor for attribute types.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeTypeValueEditor extends AbstractDialogStringValueEditor
+{
+
+ private static final String EMPTY = ""; //$NON-NLS-1$
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * This implementation opens the AttributeTypeDialog.
+ */
+ public boolean openDialog( Shell shell )
+ {
+ Object value = getValue();
+ if ( value != null && value instanceof AttributeTypeValueEditorRawValueWrapper )
+ {
+ AttributeTypeValueEditorRawValueWrapper wrapper = ( AttributeTypeValueEditorRawValueWrapper ) value;
+ AttributeTypeDialog dialog = new AttributeTypeDialog( shell, wrapper.schema, wrapper.attributeType );
+ if ( dialog.open() == TextDialog.OK && !EMPTY.equals( dialog.getAttributeType() ) )
+ {
+ setValue( dialog.getAttributeType() );
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * Returns an AttributeTypeAndValueValueEditorRawValueWrapper.
+ */
+ public Object getRawValue( IValue value )
+ {
+ return value != null ? getRawValue( value.getAttribute().getEntry().getBrowserConnection(), value.getStringValue() )
+ : null;
+ }
+
+
+ private Object getRawValue( IBrowserConnection connection, Object value )
+ {
+ Schema schema = null;
+ if ( connection != null )
+ {
+ schema = connection.getSchema();
+ }
+ if ( schema == null || value == null || !( value instanceof String ) )
+ {
+ return null;
+ }
+
+ String atValue = ( String ) value;
+ AttributeTypeValueEditorRawValueWrapper wrapper = new AttributeTypeValueEditorRawValueWrapper( schema, atValue );
+ return wrapper;
+ }
+
+ /**
+ * The AttributeTypeValueEditorRawValueWrapper is used to pass contextual
+ * information to the opened AttributeTypeDialog.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ private class AttributeTypeValueEditorRawValueWrapper
+ {
+ /**
+ * The schema, used in AttributeTypeDialog to build the list
+ * with possible attribute types.
+ */
+ private Schema schema;
+
+ /** The attribute type, used as initial value in AttributeTypeDialog. */
+ private String attributeType;
+
+
+ /**
+ * Creates a new instance of AttributeTypeValueEditorRawValueWrapper.
+ *
+ * @param schema the schema
+ * @param attributeType the attribute type
+ */
+ private AttributeTypeValueEditorRawValueWrapper( Schema schema, String attributeType )
+ {
+ super();
+ this.schema = schema;
+ this.attributeType = attributeType;
+ }
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/AttributeTypeValueEditor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/ExclusionDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/ExclusionDialog.java?rev=592011&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/ExclusionDialog.java (added)
+++ directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/ExclusionDialog.java Mon Nov 5 06:27:47 2007
@@ -0,0 +1,233 @@
+/*
+ * 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.aciitemeditor.valueeditors;
+
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.naming.InvalidNameException;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.aciitemeditor.Activator;
+import org.apache.directory.studio.ldapbrowser.common.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.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+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;
+
+
+/**
+ * This class provides a dialog to enter the Exclusion values.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+class ExclusionDialog extends Dialog
+{
+
+ /** The connection. */
+ private IBrowserConnection connection;
+
+ /** The base. */
+ private LdapDN base;
+
+ /** The initial type. */
+ private String initialType;
+
+ /** The initial DN */
+ private String initalDN;
+
+ /** The return type */
+ private String returnType;
+
+ /** The return DN */
+ private String returnDN;
+
+ private static final String EMPTY = ""; //$NON-NLS-1$
+ private static final String CHOP_BEFORE = "chopBefore"; //$NON-NLS-1$
+ private static final String CHOP_AFTER = "chopAfter"; //$NON-NLS-1$
+
+ // UI Fields
+ private Combo typeCombo;
+ private ComboViewer typeComboViewer;
+ private EntryWidget entryWidget;
+
+
+ /**
+ * Creates a new instance of ExclusionDialog.
+ *
+ * @param parentShell the parent shell
+ * @param connection the connection
+ * @param base the base DN
+ * @param exclusion the exclusion string
+ */
+ protected ExclusionDialog( Shell parentShell, IBrowserConnection connection, LdapDN base, String exclusion )
+ {
+ super( parentShell );
+ this.connection = connection;
+ this.base = base;
+
+ try
+ {
+ // for example: chopAfter: "ou=A"
+ Pattern pattern = Pattern.compile( "\\s*(chopBefore|chopAfter):\\s*\"(.*)\"\\s*" ); //$NON-NLS-1$
+ Matcher matcher = pattern.matcher( exclusion );
+ initialType = matcher.matches() ? matcher.group( 1 ) : EMPTY;
+ initalDN = matcher.matches() ? matcher.group( 2 ) : EMPTY;
+ }
+ catch ( Exception e )
+ {
+ initialType = EMPTY;
+ initalDN = EMPTY;
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell( Shell shell )
+ {
+ super.configureShell( shell );
+ shell.setText( Messages.getString( "ExclusionValueEditor.title" ) ); //$NON-NLS-1$
+ shell.setImage( Activator.getDefault().getImage( Messages.getString( "ExclusionValueEditor.icon" ) ) ); //$NON-NLS-1$
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed()
+ {
+ returnType = typeCombo.getText();
+ returnDN = entryWidget.getDn().toString();
+
+ // save dn history
+ entryWidget.saveDialogSettings();
+
+ super.okPressed();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea( Composite parent )
+ {
+ 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( 3, false ) );
+
+ BaseWidgetUtils.createLabel( composite, Messages.getString( "ExclusionValueEditor.label.type" ), 1 ); //$NON-NLS-1$
+ typeCombo = new Combo( composite, SWT.READ_ONLY );
+ String[] types = new String[2];
+ types[0] = CHOP_BEFORE;
+ types[1] = CHOP_AFTER;
+ typeComboViewer = new ComboViewer( typeCombo );
+ typeComboViewer.setContentProvider( new ArrayContentProvider() );
+ typeComboViewer.setLabelProvider( new LabelProvider() );
+ typeComboViewer.setInput( types );
+ typeComboViewer.setSelection( new StructuredSelection( CHOP_BEFORE ), true );
+ typeComboViewer.setSelection( new StructuredSelection( initialType ), true );
+ GridData gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.verticalAlignment = GridData.CENTER;
+ gridData.horizontalAlignment = GridData.BEGINNING;
+ typeCombo.setLayoutData( gridData );
+
+ BaseWidgetUtils.createLabel( composite, Messages.getString( "ExclusionValueEditor.label.rdn" ), 1 ); //$NON-NLS-1$
+ entryWidget = new EntryWidget( connection, null, base );
+ entryWidget.createWidget( composite );
+ try
+ {
+ LdapDN dn = new LdapDN( initalDN );
+ entryWidget.setInput( connection, dn, base );
+ }
+ catch ( InvalidNameException e )
+ {
+ }
+ entryWidget.addWidgetModifyListener( new WidgetModifyListener()
+ {
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ validate();
+ }
+ } );
+
+ validate();
+
+ return composite;
+ }
+
+
+ /**
+ * Validates if the dn is valid.
+ */
+ private void validate()
+ {
+ boolean valid = entryWidget.getDn() != null && entryWidget.getDn().size() > 0;
+
+ if ( getButton( IDialogConstants.OK_ID ) != null )
+ {
+ getButton( IDialogConstants.OK_ID ).setEnabled( valid );
+ }
+ }
+
+
+ /**
+ * Get the type.
+ *
+ * @return
+ * the type, null if canceled
+ */
+ public String getType()
+ {
+ return returnType;
+ }
+
+
+ /**
+ * Gets the DN.
+ *
+ * @return
+ * the DN, null if canceled
+ */
+ public String getDN()
+ {
+ return returnDN;
+ }
+}
\ No newline at end of file
Propchange: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/ExclusionDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/FilterValueEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/FilterValueEditor.java?rev=592011&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/FilterValueEditor.java (added)
+++ directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/FilterValueEditor.java Mon Nov 5 06:27:47 2007
@@ -0,0 +1,123 @@
+/*
+ * 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.aciitemeditor.valueeditors;
+
+
+import org.apache.directory.studio.ldapbrowser.common.dialogs.FilterWidgetDialog;
+import org.apache.directory.studio.ldapbrowser.common.dialogs.TextDialog;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.valueeditors.AbstractDialogStringValueEditor;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Implementation of IValueEditor for LDAP filters.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class FilterValueEditor extends AbstractDialogStringValueEditor
+{
+
+ private static final String EMPTY = ""; //$NON-NLS-1$
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * This implementation opens the FilterWidgetDialog.
+ */
+ public boolean openDialog( Shell shell )
+ {
+ Object value = getValue();
+ if ( value != null && value instanceof FilterValueEditorRawValueWrapper )
+ {
+ FilterValueEditorRawValueWrapper wrapper = ( FilterValueEditorRawValueWrapper ) value;
+ FilterWidgetDialog dialog = new FilterWidgetDialog( shell, Messages
+ .getString( "FilterValueEditor.dialog.title" ), wrapper.filter, //$NON-NLS-1$
+ wrapper.connection );
+ if ( dialog.open() == TextDialog.OK && !EMPTY.equals( dialog.getFilter() ) )
+ {
+ setValue( dialog.getFilter() );
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * Returns an AttributeTypeAndValueValueEditorRawValueWrapper.
+ */
+ public Object getRawValue( IValue value )
+ {
+ return value != null ? getRawValue( value.getAttribute().getEntry().getBrowserConnection(), value.getStringValue() )
+ : null;
+ }
+
+
+ private Object getRawValue( IBrowserConnection connection, Object value )
+ {
+ if ( connection == null || value == null || !( value instanceof String ) )
+ {
+ return null;
+ }
+
+ String filterValue = ( String ) value;
+ FilterValueEditorRawValueWrapper wrapper = new FilterValueEditorRawValueWrapper( connection, filterValue );
+ return wrapper;
+ }
+
+ /**
+ * The FilterValueEditorRawValueWrapper is used to pass contextual
+ * information to the opened FilterDialog.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ private class FilterValueEditorRawValueWrapper
+ {
+ /**
+ * The connection, used in FilterDialog to build the list
+ * with possible attribute types.
+ */
+ private IBrowserConnection connection;
+
+ /** The filter, used as initial value in FilterDialog. */
+ private String filter;
+
+
+ /**
+ * Creates a new instance of FilterValueEditorRawValueWrapper.
+ *
+ * @param schema the schema
+ * @param attributeType the attribute type
+ */
+ private FilterValueEditorRawValueWrapper( IBrowserConnection connection, String filter )
+ {
+ this.connection = connection;
+ this.filter = filter;
+ }
+ }
+}
Propchange: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/FilterValueEditor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/MaxValueCountValueEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/MaxValueCountValueEditor.java?rev=592011&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/MaxValueCountValueEditor.java (added)
+++ directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/MaxValueCountValueEditor.java Mon Nov 5 06:27:47 2007
@@ -0,0 +1,343 @@
+/*
+ * 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.aciitemeditor.valueeditors;
+
+
+import java.util.Arrays;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.directory.studio.aciitemeditor.Activator;
+import org.apache.directory.studio.ldapbrowser.common.dialogs.TextDialog;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.ListContentProposalProvider;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
+import org.apache.directory.studio.valueeditors.AbstractDialogStringValueEditor;
+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 <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class MaxValueCountValueEditor extends AbstractDialogStringValueEditor
+{
+
+ private static final String L_CURLY_TYPE = "{ type "; //$NON-NLS-1$
+ private static final String SEP_MAXCOUNT = ", maxCount "; //$NON-NLS-1$
+ private static final String R_CURLY = " }"; //$NON-NLS-1$
+ private static final String EMPTY = ""; //$NON-NLS-1$
+
+
+ /**
+ * {@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 && !EMPTY.equals( dialog.getType() ) && dialog.getMaxCount() > -1 )
+ {
+ setValue( L_CURLY_TYPE + dialog.getType() + SEP_MAXCOUNT + dialog.getMaxCount() + R_CURLY );
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * Returns an AttributeTypeAndValueValueEditorRawValueWrapper.
+ */
+ public Object getRawValue( IValue value )
+ {
+ return value != null ? getRawValue( value.getAttribute().getEntry().getBrowserConnection(), value.getStringValue() )
+ : null;
+ }
+
+
+ private Object getRawValue( IBrowserConnection 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 = EMPTY;
+ int maxCount = 0;
+ try
+ {
+ // for example: { type userPassword, maxCount 10 }
+ Pattern pattern = Pattern.compile( "\\s*\\{\\s*type\\s*([^,]*),\\s*maxCount\\s*(\\d*)\\s*\\}\\s*" ); //$NON-NLS-1$
+ Matcher matcher = pattern.matcher( stringValue );
+ type = matcher.matches() ? matcher.group( 1 ) : EMPTY;
+ 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 <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @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 <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ private class MaxValueCountDialog extends Dialog
+ {
+
+ /** 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( Messages.getString( "MaxValueCountValueEditor.title" ) ); //$NON-NLS-1$
+ shell.setImage( Activator.getDefault().getImage( Messages.getString( "MaxValueCountValueEditor.icon" ) ) ); //$NON-NLS-1$
+ }
+
+
+ /**
+ * {@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, L_CURLY_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, SEP_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, R_CURLY, 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;
+ }
+
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/MaxValueCountValueEditor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/Messages.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/Messages.java?rev=592011&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/Messages.java (added)
+++ directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/Messages.java Mon Nov 5 06:27:47 2007
@@ -0,0 +1,50 @@
+/*
+ * 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.aciitemeditor.valueeditors;
+
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+public class Messages
+{
+ private static final String BUNDLE_NAME = "org.apache.directory.studio.aciitemeditor.valueeditors.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
+
+
+ private Messages()
+ {
+ }
+
+
+ public static String getString( String key )
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString( key );
+ }
+ catch ( MissingResourceException e )
+ {
+ return '!' + key + '!';
+ }
+ }
+}
Propchange: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/Messages.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/RestrictedByValueEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/RestrictedByValueEditor.java?rev=592011&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/RestrictedByValueEditor.java (added)
+++ directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/RestrictedByValueEditor.java Mon Nov 5 06:27:47 2007
@@ -0,0 +1,362 @@
+/*
+ * 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.aciitemeditor.valueeditors;
+
+
+import java.util.Arrays;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.directory.studio.aciitemeditor.Activator;
+import org.apache.directory.studio.ldapbrowser.common.dialogs.TextDialog;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.ListContentProposalProvider;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
+import org.apache.directory.studio.valueeditors.AbstractDialogStringValueEditor;
+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 <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class RestrictedByValueEditor extends AbstractDialogStringValueEditor
+{
+
+ private static final String L_CURLY_TYPE = "{ type "; //$NON-NLS-1$
+ private static final String SEP_VALUESIN = ", valuesIn "; //$NON-NLS-1$
+ private static final String R_CURLY = " }"; //$NON-NLS-1$
+ private static final String EMPTY = ""; //$NON-NLS-1$
+
+
+ /**
+ * {@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 && !EMPTY.equals( dialog.getType() )
+ && !EMPTY.equals( dialog.getValuesIn() ) )
+ {
+ setValue( L_CURLY_TYPE + dialog.getType() + SEP_VALUESIN + dialog.getValuesIn() + R_CURLY );
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * Returns an AttributeTypeAndValueValueEditorRawValueWrapper.
+ */
+ public Object getRawValue( IValue value )
+ {
+ return value != null ? getRawValue( value.getAttribute().getEntry().getBrowserConnection(), value.getStringValue() )
+ : null;
+ }
+
+
+ private Object getRawValue( IBrowserConnection 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 = EMPTY;
+ String valuesIn = EMPTY;
+ try
+ {
+ // for example: { type sn, valuesIn cn }
+ Pattern pattern = Pattern
+ .compile( "\\s*\\{\\s*type\\s*([^,\\s]*)\\s*,\\s*valuesIn\\s*([^,\\s]*)\\s*\\}\\s*" ); //$NON-NLS-1$
+ Matcher matcher = pattern.matcher( stringValue );
+ type = matcher.matches() ? matcher.group( 1 ) : EMPTY;
+ valuesIn = matcher.matches() ? matcher.group( 2 ) : EMPTY;
+ }
+ 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 <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @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 <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ private class RestrictedByDialog extends Dialog
+ {
+
+ /** 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( Messages.getString( "RestrictedByValueEditor.title" ) ); //$NON-NLS-1$
+ shell.setImage( Activator.getDefault().getImage( Messages.getString( "RestrictedByValueEditor.icon" ) ) ); //$NON-NLS-1$
+ }
+
+
+ /**
+ * {@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, L_CURLY_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, SEP_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, R_CURLY, 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;
+ }
+
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/RestrictedByValueEditor.java
------------------------------------------------------------------------------
svn:eol-style = native