directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r531576 - in /directory/ldapstudio/trunk/ldapstudio-aciitemeditor: ./ META-INF/ src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/ src/main/java/org/apache...
Date Mon, 23 Apr 2007 19:55:07 GMT
Author: seelmann
Date: Mon Apr 23 12:55:06 2007
New Revision: 531576

URL: http://svn.apache.org/viewvc?view=rev&rev=531576
Log:
- Moved dependencies to jars plugin
- Modified SubtreeValueEditor so it could be used as value editor
- Added subtreeSpecification value editor to plugin.xml
- Added filter or refinement widget to SubtreeValueEditor 
- Introduced local names for subtreeSpecification base and exclusion base

Added:
    directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/ExclusionDialog.java
    directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/SubtreeSpecificationDialog.java
Removed:
    directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/ExclusionValueEditor.java
Modified:
    directory/ldapstudio/trunk/ldapstudio-aciitemeditor/.classpath
    directory/ldapstudio/trunk/ldapstudio-aciitemeditor/META-INF/MANIFEST.MF
    directory/ldapstudio/trunk/ldapstudio-aciitemeditor/build.xml
    directory/ldapstudio/trunk/ldapstudio-aciitemeditor/ivy.xml
    directory/ldapstudio/trunk/ldapstudio-aciitemeditor/plugin.xml
    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/UserClassWrapperFactory.java
    directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/AttributeTypeAndValueValueEditor.java
    directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/SubtreeValueEditor.java
    directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/resources/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/messages.properties

Modified: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/.classpath
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/.classpath?view=diff&rev=531576&r1=531575&r2=531576
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/.classpath (original)
+++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/.classpath Mon Apr 23 12:55:06 2007
@@ -2,11 +2,6 @@
 <classpath>
 	<classpathentry kind="src" path="src/main/java"/>
 	<classpathentry kind="src" path="src/main/resources"/>
-	<classpathentry exported="true" kind="lib" path="lib/nlog4j-1.2.25.jar"/>
-	<classpathentry exported="true" kind="lib" path="lib/commons-collections-3.1.jar"/>
-	<classpathentry exported="true" kind="lib" path="lib/shared-asn1-0.9.6-SNAPSHOT.jar"/>
-	<classpathentry exported="true" kind="lib" path="lib/shared-ldap-0.9.6-SNAPSHOT.jar"/>
-	<classpathentry kind="lib" path="lib/antlr-2.7.6.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry kind="output" path="target/classes"/>

Modified: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/META-INF/MANIFEST.MF?view=diff&rev=531576&r1=531575&r2=531576
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/META-INF/MANIFEST.MF (original)
+++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/META-INF/MANIFEST.MF Mon Apr 23 12:55:06 2007
@@ -17,8 +17,4 @@
  org.apache.directory.ldapstudio.browser.common,
  org.apache.directory.ldapstudio.valueeditors
 Eclipse-LazyStart: true
-Bundle-ClassPath: .,
- lib/shared-ldap-0.9.6-SNAPSHOT.jar,
- lib/shared-asn1-0.9.6-SNAPSHOT.jar,
- lib/commons-collections-3.1.jar,
- lib/nlog4j-1.2.24.jar
+Bundle-ClassPath: .

Modified: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/build.xml
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/build.xml?view=diff&rev=531576&r1=531575&r2=531576
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/build.xml (original)
+++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/build.xml Mon Apr 23 12:55:06 2007
@@ -35,7 +35,9 @@
 	<!--               RESOLVE              -->
 	<!-- ================================== -->
 	<target name="resolve" description="--> retreive dependencies with ivy">
-		<ivy:retrieve/>
+		<mkdir dir="${basedir}/${lib.dir}" />
+		<ivy:retrieve/>
+		<ant dir="../ldapstudio-jars" inheritAll="no" target="resolve" />
 	</target>
 
 	<!-- ================================== -->
@@ -48,6 +50,7 @@
 				<include name="**/*.jar"/>
 			</fileset>
 			<fileset dir="${lib.dir}" />
+			<fileset dir="../ldapstudio-jars/lib/" />
 			<pathelement location="${basedir}/../ldapstudio-browser-core/target/classes"/>
 			<pathelement location="${basedir}/../ldapstudio-browser-core/target/build"/>
 			<pathelement location="${basedir}/../ldapstudio-browser-common/target/classes"/>

Modified: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/ivy.xml
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/ivy.xml?view=diff&rev=531576&r1=531575&r2=531576
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/ivy.xml (original)
+++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/ivy.xml Mon Apr 23 12:55:06 2007
@@ -18,7 +18,4 @@
 -->
 <ivy-module version="1.0">
 	<info organisation="org.apache.directory.ldapstudio" module="ldapstudio-aciitemeditor"/>
-    <dependencies>
-		<dependency org="org.apache.directory.shared" name="shared-ldap" rev="0.9.6-SNAPSHOT"/>
-    </dependencies>
 </ivy-module>

Modified: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/plugin.xml
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/plugin.xml?view=diff&rev=531576&r1=531575&r2=531576
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/plugin.xml (original)
+++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/plugin.xml Mon Apr 23 12:55:06 2007
@@ -10,6 +10,12 @@
             name="ACI Item Editor">
          <syntax syntaxOID="1.3.6.1.4.1.1466.115.121.1.1"/>
       </valueEditor>
+      <valueEditor
+            class="org.apache.directory.ldapstudio.aciitemeditor.valueeditors.SubtreeValueEditor"
+            icon="resources/icons/subtreeeditor.png"
+            name="Subtree Specification Editor">
+         <syntax syntaxOID="1.3.6.1.4.1.1466.115.121.1.45"/>
+      </valueEditor>
    </extension>
    <extension
          point="org.eclipse.ui.editors.templates">

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=531576&r1=531575&r2=531576
==============================================================================
--- 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 Mon Apr 23 12:55:06 2007
@@ -24,6 +24,11 @@
 
 import org.apache.directory.ldapstudio.aciitemeditor.ACIItemValueWithContext;
 import org.apache.directory.ldapstudio.aciitemeditor.Activator;
+import org.apache.directory.ldapstudio.browser.core.internal.model.Attribute;
+import org.apache.directory.ldapstudio.browser.core.internal.model.Value;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
 import org.apache.directory.ldapstudio.valueeditors.AbstractDialogStringValueEditor;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
@@ -277,7 +282,19 @@
      */
     private void addValue()
     {
-        Object oldRawValue = valueEditor.getRawValue( context.getConnection(), "" ); //$NON-NLS-1$
+        
+        Object oldRawValue;
+        try
+        {
+            IAttribute attribute = new Attribute( context.getEntry(), "" ); //$NON-NLS-1$
+            IValue value = new Value( attribute, "" ); //$NON-NLS-1$
+            oldRawValue = valueEditor.getRawValue( value ); //$NON-NLS-1$
+        }
+        catch ( ModelModificationException e )
+        {
+            oldRawValue = valueEditor.getRawValue( context.getConnection(), "" ); //$NON-NLS-1$
+        }
+        
 
         CellEditor cellEditor = valueEditor.getCellEditor();
         cellEditor.setValue( oldRawValue );
@@ -303,7 +320,17 @@
         String oldValue = getSelectedValue();
         if ( oldValue != null )
         {
-            Object oldRawValue = valueEditor.getRawValue( context.getConnection(), oldValue );
+            Object oldRawValue;
+            try
+            {
+                IAttribute attribute = new Attribute( context.getEntry(), "" ); //$NON-NLS-1$
+                IValue value = new Value( attribute, oldValue ); //$NON-NLS-1$
+                oldRawValue = valueEditor.getRawValue( value ); //$NON-NLS-1$
+            }
+            catch ( ModelModificationException e )
+            {
+                oldRawValue = valueEditor.getRawValue( context.getConnection(), oldValue );
+            }
 
             CellEditor cellEditor = valueEditor.getCellEditor();
             cellEditor.setValue( oldRawValue );

Modified: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/UserClassWrapperFactory.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/UserClassWrapperFactory.java?view=diff&rev=531576&r1=531575&r2=531576
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/UserClassWrapperFactory.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/UserClassWrapperFactory.java Mon Apr 23 12:55:06 2007
@@ -6,16 +6,16 @@
  *  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. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.ldapstudio.aciitemeditor.model;
 
@@ -37,7 +37,7 @@
 
     /**
      * Creates the user class wrappers.
-     * 
+     *
      * @return the user class wrapper[]
      */
     public static final UserClassWrapper[] createUserClassWrappers()
@@ -67,7 +67,7 @@
                 // subtree
                 new UserClassWrapper( UserClass.Subtree.class, "", //$NON-NLS-1$
                     "", //$NON-NLS-1$
-                    new SubtreeValueEditor()
+                    new SubtreeValueEditor( false )
                 ) };
 
         return userClassWrappers;

Modified: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/AttributeTypeAndValueValueEditor.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/AttributeTypeAndValueValueEditor.java?view=diff&rev=531576&r1=531575&r2=531576
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/AttributeTypeAndValueValueEditor.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/AttributeTypeAndValueValueEditor.java Mon Apr 23 12:55:06 2007
@@ -21,7 +21,6 @@
 package org.apache.directory.ldapstudio.aciitemeditor.valueeditors;
 
 
-import org.apache.directory.ldapstudio.aciitemeditor.Activator;
 import org.apache.directory.ldapstudio.browser.common.dialogs.TextDialog;
 import org.apache.directory.ldapstudio.browser.core.model.IConnection;
 import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;

Added: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/ExclusionDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/ExclusionDialog.java?view=auto&rev=531576
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/ExclusionDialog.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/ExclusionDialog.java Mon Apr 23 12:55:06 2007
@@ -0,0 +1,213 @@
+package org.apache.directory.ldapstudio.aciitemeditor.valueeditors;
+
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.directory.ldapstudio.aciitemeditor.Activator;
+import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyListener;
+import org.apache.directory.ldapstudio.browser.common.widgets.search.EntryWidget;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.NameException;
+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 IConnection connection;
+
+    /** The base. */
+    private DN base;
+
+    /** The initial typ. */
+    private String initialType;
+
+    /** The inital 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, IConnection connection, DN 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
+        {
+            DN dn = new DN( initalDN );
+            entryWidget.setInput( connection, dn, base );
+        }
+        catch ( NameException 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().getRdns().length > 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

Added: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/SubtreeSpecificationDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/SubtreeSpecificationDialog.java?view=auto&rev=531576
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/SubtreeSpecificationDialog.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/SubtreeSpecificationDialog.java Mon Apr 23 12:55:06 2007
@@ -0,0 +1,722 @@
+package org.apache.directory.ldapstudio.aciitemeditor.valueeditors;
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.directory.ldapstudio.aciitemeditor.Activator;
+import org.apache.directory.ldapstudio.browser.common.dialogs.TextDialog;
+import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyListener;
+import org.apache.directory.ldapstudio.browser.common.widgets.search.EntryWidget;
+import org.apache.directory.ldapstudio.browser.common.widgets.search.FilterWidget;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.NameException;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.subtree.BaseSubtreeSpecification;
+import org.apache.directory.shared.ldap.subtree.SubtreeSpecification;
+import org.apache.directory.shared.ldap.subtree.SubtreeSpecificationParser;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Spinner;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * This class provides a dialog to enter the Subtree Specification value.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+class SubtreeSpecificationDialog extends Dialog
+{
+
+    /** The parser. */
+    private final SubtreeSpecificationParser parser = new SubtreeSpecificationParser( null );
+
+    /** The connection */
+    private IConnection connection;
+
+    /** The subentry's DN */
+    private DN subentryDN;
+
+    /** Flag indicating if the refinement or filter widget should be visible */
+    private boolean refinementOrFilterVisible;
+
+    /** The initial SubtreeSpecification */
+    private SubtreeSpecification subtreeSpecification;
+
+    /** The Exclusions List */
+    private List<String> exclusions;
+
+    /** The returned SubtreeSpecification */
+    private String returnValue;
+
+    // UI Fields
+    private EntryWidget entryWidget;
+    private Spinner minimumSpinner;
+    private Spinner maximumSpinner;
+    private TableViewer exclusionsTableViewer;
+    private Button exclusionsTableAddButton;
+    private Button exclusionsTableEditButton;
+    private Button exclusionsTableDeleteButton;
+    private Button refinementButton;
+    private Text refinementText;
+    private Button filterButton;
+    private FilterWidget filterWidget;
+
+
+    /**
+     * Creates a new instance of SubtreeSpecificationDialog.
+     *
+     * @param shell
+     *      the shell to use
+     * @param connection
+     *      the connection to use
+     * @param subentryDN
+     *      the subentry's DN
+     * @param initialSubtreeSpecification
+     *      the initial SubtreeSpecification
+     * @param refinementOrFilterVisible
+     *      true if the refinement of filter widget should be visible
+     */
+    SubtreeSpecificationDialog( Shell shell, IConnection connection, DN subentryDN,
+        String initialSubtreeSpecification, boolean refinementOrFilterVisible )
+    {
+        super( shell );
+        this.connection = connection;
+        this.subentryDN = subentryDN;
+        this.refinementOrFilterVisible = refinementOrFilterVisible;
+
+        // parse
+        try
+        {
+            subtreeSpecification = parser.parse( initialSubtreeSpecification );
+            if ( subtreeSpecification == null )
+            {
+                subtreeSpecification = new BaseSubtreeSpecification();
+            }
+        }
+        catch ( ParseException pe )
+        {
+            // TODO
+            pe.printStackTrace();
+            subtreeSpecification = new BaseSubtreeSpecification();
+        }
+
+        exclusions = new ArrayList<String>();
+        Set chopBeforeExclusions = subtreeSpecification.getChopBeforeExclusions();
+        for ( Object chopBeforeExclusion : chopBeforeExclusions )
+        {
+            LdapDN dn = ( LdapDN ) chopBeforeExclusion;
+            exclusions.add( "chopBefore: \"" + dn.toNormName() + "\"" ); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+
+        Set chopAfterExclusions = subtreeSpecification.getChopAfterExclusions();
+        for ( Object chopAfterExclusion : chopAfterExclusions )
+        {
+            LdapDN dn = ( LdapDN ) chopAfterExclusion;
+            exclusions.add( "chopAfter: \"" + dn.toNormName() + "\"" ); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+
+        returnValue = null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
+    protected void configureShell( Shell newShell )
+    {
+        super.configureShell( newShell );
+        newShell.setText( Messages.getString( "SubtreeValueEditor.title" ) ); //$NON-NLS-1$
+        newShell.setImage( Activator.getDefault().getImage( Messages.getString( "SubtreeValueEditor.icon" ) ) ); //$NON-NLS-1$
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+     */
+    protected void okPressed()
+    {
+        // set return value
+        //returnValue = buildSubreeSpecification();
+        StringBuffer sb = new StringBuffer();
+        subtreeSpecification.printToBuffer( sb );
+        returnValue = sb.toString();
+
+        // save filter and dn history
+        filterWidget.saveDialogSettings();
+        entryWidget.saveDialogSettings();
+
+        super.okPressed();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+     */
+    protected Control createDialogArea( Composite parent )
+    {
+        Composite outer = ( Composite ) super.createDialogArea( parent );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+        outer.setLayoutData( gd );
+
+        Composite composite = BaseWidgetUtils.createColumnContainer( outer, 3, 1 );
+
+        BaseWidgetUtils.createLabel( composite, Messages.getString( "SubtreeValueEditor.label.base" ), 1 ); //$NON-NLS-1$
+
+        DN base = null;
+        DN suffix = null;
+        try
+        {
+            base = new DN( subtreeSpecification.getBase().toNormName() );
+            suffix = subentryDN != null ? subentryDN.getParentDn() : null;
+        }
+        catch ( NameException e )
+        {
+        }
+        entryWidget = new EntryWidget( connection, base, suffix );
+        entryWidget.createWidget( composite );
+        entryWidget.addWidgetModifyListener( new WidgetModifyListener()
+        {
+            public void widgetModified( WidgetModifyEvent event )
+            {
+                validate();
+            }
+        } );
+
+        GridData spinnersGridData = new GridData();
+        spinnersGridData.grabExcessHorizontalSpace = true;
+        spinnersGridData.verticalAlignment = GridData.CENTER;
+        spinnersGridData.horizontalSpan = 2;
+        spinnersGridData.horizontalAlignment = GridData.BEGINNING;
+        spinnersGridData.widthHint = 3 * 12;
+
+        BaseWidgetUtils.createLabel( composite, Messages.getString( "SubtreeValueEditor.label.minimum" ), 1 ); //$NON-NLS-1$
+        minimumSpinner = new Spinner( composite, SWT.BORDER );
+        minimumSpinner.setMinimum( 0 );
+        minimumSpinner.setMaximum( Integer.MAX_VALUE );
+        minimumSpinner.setDigits( 0 );
+        minimumSpinner.setIncrement( 1 );
+        minimumSpinner.setPageIncrement( 100 );
+        minimumSpinner.setSelection( subtreeSpecification.getMinBaseDistance() );
+        minimumSpinner.setLayoutData( spinnersGridData );
+        minimumSpinner.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent event )
+            {
+                validate();
+            }
+        } );
+
+        BaseWidgetUtils.createLabel( composite, Messages.getString( "SubtreeValueEditor.label.maximum" ), 1 ); //$NON-NLS-1$
+        maximumSpinner = new Spinner( composite, SWT.BORDER );
+        maximumSpinner.setMinimum( 0 );
+        maximumSpinner.setMaximum( Integer.MAX_VALUE );
+        maximumSpinner.setDigits( 0 );
+        maximumSpinner.setIncrement( 1 );
+        maximumSpinner.setPageIncrement( 100 );
+        maximumSpinner.setSelection( subtreeSpecification.getMaxBaseDistance() );
+        maximumSpinner.setLayoutData( spinnersGridData );
+        maximumSpinner.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent event )
+            {
+                validate();
+            }
+        } );
+
+        createExclusionsTable( composite );
+
+        if ( refinementOrFilterVisible )
+        {
+            BaseWidgetUtils.createSpacer( composite, 3 );
+            createRefinementOrFilterWidgets( composite );
+        }
+
+        applyDialogFont( outer );
+
+        initFromInput();
+
+        validate();
+
+        return outer;
+    }
+
+
+    /**
+     * Initializes the Value Editor from the input.
+     */
+    private void initFromInput()
+    {
+
+    }
+
+
+    /**
+     * Creates the Exclusions Table.
+     *
+     * @param composite
+     *      the composite
+     */
+    private void createExclusionsTable( Composite composite )
+    {
+        GridData tableGridData = new GridData();
+        tableGridData.grabExcessHorizontalSpace = true;
+        tableGridData.verticalAlignment = GridData.FILL;
+        tableGridData.horizontalAlignment = GridData.FILL;
+        tableGridData.heightHint = 100;
+
+        BaseWidgetUtils.createLabel( composite, Messages.getString( "SubtreeValueEditor.label.exclusions" ), 1 ); //$NON-NLS-1$
+        Table exclusionsTable = new Table( composite, SWT.BORDER );
+        exclusionsTable.setHeaderVisible( false );
+        exclusionsTable.setLayoutData( tableGridData );
+        exclusionsTable.setLinesVisible( false );
+        exclusionsTableViewer = new TableViewer( exclusionsTable );
+        exclusionsTableViewer.setContentProvider( new ArrayContentProvider() );
+        exclusionsTableViewer.setLabelProvider( new LabelProvider() );
+        exclusionsTableViewer.setInput( exclusions );
+        exclusionsTableViewer.addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                valueSelectedExclusionsTable();
+            }
+        } );
+        exclusionsTableViewer.addDoubleClickListener( new IDoubleClickListener()
+        {
+            public void doubleClick( DoubleClickEvent event )
+            {
+                editValueExclusionsTable();
+            }
+        } );
+
+        GridLayout gridLayout = new GridLayout();
+        gridLayout.marginWidth = 0;
+        gridLayout.marginHeight = 0;
+        GridData gridData = new GridData();
+        gridData.horizontalAlignment = GridData.CENTER;
+        gridData.grabExcessHorizontalSpace = false;
+        gridData.grabExcessVerticalSpace = false;
+        gridData.verticalAlignment = GridData.FILL;
+
+        Composite buttonComposite = new Composite( composite, SWT.NONE );
+        buttonComposite.setLayoutData( gridData );
+        buttonComposite.setLayout( gridLayout );
+
+        GridData buttonGridData = new GridData();
+        buttonGridData.horizontalAlignment = GridData.FILL;
+        buttonGridData.grabExcessHorizontalSpace = false;
+        buttonGridData.verticalAlignment = GridData.BEGINNING;
+        buttonGridData.widthHint = Activator.getButtonWidth( buttonComposite );
+
+        exclusionsTableAddButton = new Button( buttonComposite, SWT.PUSH );
+        exclusionsTableAddButton.setText( Messages.getString( "SubtreeValueEditor.button.add" ) ); //$NON-NLS-1$
+        exclusionsTableAddButton.setLayoutData( buttonGridData );
+        exclusionsTableAddButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                addValueExclusionsTable();
+            }
+        } );
+
+        exclusionsTableEditButton = new Button( buttonComposite, SWT.PUSH );
+        exclusionsTableEditButton.setText( Messages.getString( "SubtreeValueEditor.button.edit" ) ); //$NON-NLS-1$
+        exclusionsTableEditButton.setLayoutData( buttonGridData );
+        exclusionsTableEditButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                editValueExclusionsTable();
+            }
+        } );
+        exclusionsTableEditButton.setEnabled( false );
+
+        exclusionsTableDeleteButton = new Button( buttonComposite, SWT.PUSH );
+        exclusionsTableDeleteButton.setText( Messages.getString( "SubtreeValueEditor.button.delete" ) ); //$NON-NLS-1$
+        exclusionsTableDeleteButton.setLayoutData( buttonGridData );
+        exclusionsTableDeleteButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                deleteValueExclusionsTable();
+            }
+        } );
+        exclusionsTableDeleteButton.setEnabled( false );
+    }
+
+
+    /**
+     * Creates the refinement or filter widgets
+     *
+     * @param composite
+     *      the composite
+     */
+    private void createRefinementOrFilterWidgets( Composite parent )
+    {
+        // Messages.getString( "SubtreeValueEditor.label.exclusions" )
+        BaseWidgetUtils.createLabel( parent, Messages
+            .getString( "SubtreeValueEditor.SubtreeValueEditor.label.refinementOrFilter" ), 1 ); //$NON-NLS-1$
+
+        Composite composite = BaseWidgetUtils.createColumnContainer( parent, 2, 2 );
+
+        // refinement redio button
+        refinementButton = BaseWidgetUtils.createRadiobutton( composite, Messages
+            .getString( "SubtreeValueEditor.SubtreeValueEditor.label.refinement" ), 2 ); //$NON-NLS-1$
+
+        // refinement text
+        refinementText = new Text( composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        gd.horizontalSpan = 2;
+        gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+        gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 6 );
+        refinementText.setLayoutData( gd );
+        try
+        {
+            StringBuffer refinementBuffer = new StringBuffer();
+            if ( subtreeSpecification.getRefinement() != null )
+            {
+                subtreeSpecification.getRefinement().printRefinementToBuffer( refinementBuffer );
+            }
+            refinementText.setText( refinementBuffer.toString().trim() );
+            refinementText.setEnabled( true );
+            refinementButton.setSelection( true );
+        }
+        catch ( UnsupportedOperationException e )
+        {
+            // thrown if the ExprNode doesn't represent a valid refinement
+            refinementText.setText( "" ); //$NON-NLS-1$
+            refinementText.setEnabled( false );
+            refinementButton.setSelection( false );
+        }
+
+        // filter radio button
+        filterButton = BaseWidgetUtils.createRadiobutton( composite, Messages
+            .getString( "SubtreeValueEditor.SubtreeValueEditor.label.filter" ), 2 ); //$NON-NLS-1$
+
+        // filter widget
+        StringBuffer filterBuffer = new StringBuffer();
+        if ( subtreeSpecification.getRefinement() != null )
+        {
+            subtreeSpecification.getRefinement().printToBuffer( filterBuffer );
+        }
+        filterWidget = new FilterWidget( connection, filterBuffer.toString().trim() );
+        filterWidget.createWidget( composite );
+        filterButton.setSelection( !refinementButton.getSelection() );
+        filterWidget.setEnabled( !refinementButton.getSelection() );
+
+        // add listeners
+        refinementButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                refinementText.setEnabled( true );
+                //filterButton.setSelection( false );
+                filterWidget.setEnabled( false );
+                validate();
+            }
+        } );
+        refinementText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent event )
+            {
+                validate();
+            }
+        } );
+        filterButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                //refinementButton.setSelection( false );
+                refinementText.setEnabled( false );
+                filterWidget.setEnabled( true );
+                validate();
+            }
+        } );
+        filterWidget.addWidgetModifyListener( new WidgetModifyListener()
+        {
+            public void widgetModified( WidgetModifyEvent event )
+            {
+                validate();
+            }
+        } );
+    }
+
+
+    /**
+     * Validates if the composed subtree specification is valid.
+     */
+    private void validate()
+    {
+        boolean valid = true;
+
+        DN base = entryWidget.getDn();
+        valid &= base != null;
+
+        String ss = buildSubreeSpecification();
+
+        try
+        {
+            subtreeSpecification = parser.parse( ss );
+            valid &= true;
+        }
+        catch ( ParseException pe )
+        {
+            subtreeSpecification = null;
+            valid &= false;
+        }
+
+        if ( getButton( IDialogConstants.OK_ID ) != null )
+        {
+            getButton( IDialogConstants.OK_ID ).setEnabled( valid );
+        }
+
+        //System.out.println("1:"  + ss);
+        //StringBuffer sb = new StringBuffer();
+        //subtreeSpecification.printToBuffer( sb );
+        //System.out.println("2:"  + sb.toString());
+    }
+
+
+    private String buildSubreeSpecification()
+    {
+        // build subtree specification tree
+        StringBuffer sb = new StringBuffer();
+        sb.append( "{" ); //$NON-NLS-1$
+
+        // Adding base
+        DN base = entryWidget.getDn();
+        if ( base != null && !SubtreeValueEditor.EMPTY.equals( base.toString() ) )
+        {
+            sb.append( " base \"" + base.toString() + "\"," ); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+
+        // Adding Minimum
+        int minimum = minimumSpinner.getSelection();
+        if ( minimum != 0 )
+        {
+            sb.append( " minimum " + minimum + "," ); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+
+        // Adding Maximum
+        int maximum = maximumSpinner.getSelection();
+        if ( maximum != 0 )
+        {
+            sb.append( " maximum " + maximum + "," ); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+
+        // Adding Exclusions
+        if ( !exclusions.isEmpty() )
+        {
+            sb.append( " specificExclusions {" ); //$NON-NLS-1$
+
+            for ( Iterator<String> it = exclusions.iterator(); it.hasNext(); )
+            {
+                sb.append( " " + it.next() ); //$NON-NLS-1$
+
+                if ( it.hasNext() )
+                {
+                    sb.append( "," ); //$NON-NLS-1$
+                }
+            }
+
+            sb.append( " }," ); //$NON-NLS-1$
+        }
+
+        // Add Refinement or Filter
+        String refinementOrFilter = ""; //$NON-NLS-1$
+        if ( refinementOrFilterVisible )
+        {
+            if ( refinementButton.getSelection() )
+            {
+                refinementOrFilter = refinementText.getText();
+            }
+            else
+            {
+                refinementOrFilter = filterWidget.getFilter();
+            }
+        }
+        else
+        {
+            refinementOrFilter = ""; //$NON-NLS-1$
+        }
+        if ( refinementOrFilter != null && !SubtreeValueEditor.EMPTY.equals( refinementOrFilter ) )
+        {
+            sb.append( " specificationFilter " + refinementOrFilter + "," ); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+
+        // Removing the last ','
+        if ( sb.charAt( sb.length() - 1 ) == ',' )
+        {
+            sb.deleteCharAt( sb.length() - 1 );
+        }
+
+        sb.append( " }" ); //$NON-NLS-1$
+
+        return sb.toString();
+    }
+
+
+    /**
+     * Called when value is selected in Exclusions table viewer.
+     * Updates the enabled/disabled state of the buttons.
+     */
+    private void valueSelectedExclusionsTable()
+    {
+        String value = getSelectedValueExclusionsTable();
+
+        if ( value == null )
+        {
+            exclusionsTableEditButton.setEnabled( false );
+            exclusionsTableDeleteButton.setEnabled( false );
+        }
+        else
+        {
+            exclusionsTableEditButton.setEnabled( true );
+            exclusionsTableDeleteButton.setEnabled( true );
+        }
+    }
+
+
+    /**
+     * Retuns the current selection in the Exclusions table viewer.
+     *
+     * @return
+     *      the value that is selected in the Exclusions table viewer, or null.
+     */
+    private String getSelectedValueExclusionsTable()
+    {
+        String value = null;
+
+        IStructuredSelection selection = ( IStructuredSelection ) exclusionsTableViewer.getSelection();
+        if ( !selection.isEmpty() )
+        {
+            Object element = selection.getFirstElement();
+            if ( element instanceof String )
+            {
+                value = ( String ) element;
+            }
+        }
+
+        return value;
+    }
+
+
+    /**
+     * Opens the editor and adds the new Exclusion value to the list.
+     */
+    private void addValueExclusionsTable()
+    {
+        DN chopBase = null;
+        try
+        {
+            chopBase = new DN( subtreeSpecification.getBase().toNormName() );
+        }
+        catch ( NameException e )
+        {
+        }
+        if ( subentryDN != null && subentryDN.getParentDn() != null )
+        {
+            DN suffix = subentryDN != null ? subentryDN.getParentDn() : null;
+            chopBase = new DN( chopBase, suffix );
+        }
+
+        ExclusionDialog dialog = new ExclusionDialog( getShell(), connection, chopBase, "" ); //$NON-NLS-1$
+        if ( dialog.open() == TextDialog.OK && !SubtreeValueEditor.EMPTY.equals( dialog.getType() ) && !SubtreeValueEditor.EMPTY.equals( dialog.getDN() ) )
+        {
+            String newValue = dialog.getType() + ": \"" + dialog.getDN() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+            exclusions.add( newValue );
+            exclusionsTableViewer.refresh();
+            validate();
+        }
+    }
+
+
+    /**
+     * Opens the editor with the currently selected Exclusion
+     * value and puts the modified value into the list.
+     */
+    private void editValueExclusionsTable()
+    {
+        String oldValue = getSelectedValueExclusionsTable();
+        if ( oldValue != null )
+        {
+            DN chopBase = null;
+            try
+            {
+                chopBase = new DN( subtreeSpecification.getBase().toNormName() );
+            }
+            catch ( NameException e )
+            {
+            }
+            if ( subentryDN != null && subentryDN.getParentDn() != null )
+            {
+                DN suffix = subentryDN != null ? subentryDN.getParentDn() : null;
+                chopBase = new DN( chopBase, suffix );
+            }
+
+            ExclusionDialog dialog = new ExclusionDialog( getShell(), connection, chopBase, oldValue );
+            if ( dialog.open() == TextDialog.OK && !SubtreeValueEditor.EMPTY.equals( dialog.getType() )
+                && !SubtreeValueEditor.EMPTY.equals( dialog.getDN() ) )
+            {
+                String newValue = dialog.getType() + ": \"" + dialog.getDN() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+                exclusions.remove( oldValue );
+                exclusions.add( newValue );
+                exclusionsTableViewer.refresh();
+                validate();
+            }
+        }
+    }
+
+
+    /**
+     * Deletes the currently selected Exclusion value from list.
+     */
+    private void deleteValueExclusionsTable()
+    {
+        String value = getSelectedValueExclusionsTable();
+        if ( value != null )
+        {
+            exclusions.remove( value );
+            exclusionsTableViewer.refresh();
+            validate();
+        }
+    }
+
+
+    /**
+     * Gets the subtree specification value or null if canceled.
+     *
+     * @return the subtree specification value or null if canceled
+     */
+    public String getSubtreeSpecificationValue()
+    {
+        return returnValue;
+    }
+}
\ No newline at end of file

Modified: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/SubtreeValueEditor.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/SubtreeValueEditor.java?view=diff&rev=531576&r1=531575&r2=531576
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/SubtreeValueEditor.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/SubtreeValueEditor.java Mon Apr 23 12:55:06 2007
@@ -6,60 +6,28 @@
  *  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. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.ldapstudio.aciitemeditor.valueeditors;
 
 
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
 
-import org.apache.directory.ldapstudio.aciitemeditor.Activator;
 import org.apache.directory.ldapstudio.browser.common.dialogs.TextDialog;
-import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils;
-import org.apache.directory.ldapstudio.browser.common.widgets.search.EntryWidget;
 import org.apache.directory.ldapstudio.browser.core.model.DN;
 import org.apache.directory.ldapstudio.browser.core.model.IConnection;
-import org.apache.directory.ldapstudio.browser.core.model.NameException;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
 import org.apache.directory.ldapstudio.valueeditors.AbstractDialogStringValueEditor;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.subtree.BaseSubtreeSpecification;
-import org.apache.directory.shared.ldap.subtree.SubtreeSpecification;
-import org.apache.directory.shared.ldap.subtree.SubtreeSpecificationParser;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
+import org.apache.directory.ldapstudio.valueeditors.ValueEditorManager;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Spinner;
-import org.eclipse.swt.widgets.Table;
 
 
 /**
@@ -70,7 +38,29 @@
  */
 public class SubtreeValueEditor extends AbstractDialogStringValueEditor
 {
-    private static final String EMPTY = ""; //$NON-NLS-1$
+    static final String EMPTY = ""; //$NON-NLS-1$
+
+    private boolean refinementOrFilterVisible;
+
+
+    /**
+     * Default constructor, used by the {@link ValueEditorManager}.
+     */
+    public SubtreeValueEditor()
+    {
+        this.refinementOrFilterVisible = true;
+    }
+
+
+    /**
+     * Default constructor, used by the {@link ValueEditorManager}.
+     *
+     * @param refinementOrFilterVisible true if the refinement or filter widget should be visible
+     */
+    public SubtreeValueEditor( boolean refinementOrFilterVisible )
+    {
+        this.refinementOrFilterVisible = refinementOrFilterVisible;
+    }
 
 
     /* (non-Javadoc)
@@ -82,66 +72,12 @@
         if ( value != null && value instanceof SubtreeSpecificationValueWrapper )
         {
             SubtreeSpecificationValueWrapper wrapper = ( SubtreeSpecificationValueWrapper ) value;
+
             SubtreeSpecificationDialog dialog = new SubtreeSpecificationDialog( shell, wrapper.connection,
-                wrapper.subtreeSpecification );
-            if ( dialog.open() == TextDialog.OK
-                && ( ( dialog.getBase() != null && !EMPTY.equals( dialog.getBase() ) ) || dialog.getMinimum() != 0
-                    || dialog.getMaximum() != 0 || !dialog.getExclusions().isEmpty() ) )
+                wrapper.subentryDN, wrapper.subtreeSpecification, refinementOrFilterVisible );
+            if ( dialog.open() == TextDialog.OK && dialog.getSubtreeSpecificationValue() != null )
             {
-                String base = dialog.getBase();
-                int minimum = dialog.getMinimum();
-                int maximum = dialog.getMaximum();
-                List<String> exclusions = dialog.getExclusions();
-
-                StringBuffer sb = new StringBuffer();
-                sb.append( "{" ); //$NON-NLS-1$
-
-                // Adding base
-                if ( base != null && !EMPTY.equals( base ) )
-                {
-                    sb.append( " base \"" + base + "\"," ); //$NON-NLS-1$ //$NON-NLS-2$
-                }
-
-                // Adding Minimum
-                if ( minimum != 0 )
-                {
-                    sb.append( " minimum " + minimum + "," ); //$NON-NLS-1$ //$NON-NLS-2$
-                }
-
-                // Adding Maximum
-                if ( maximum != 0 )
-                {
-                    sb.append( " maximum " + maximum + "," ); //$NON-NLS-1$ //$NON-NLS-2$
-                }
-
-                // Adding Exclusions
-                if ( !exclusions.isEmpty() )
-                {
-                    sb.append( " specificExclusions {" ); //$NON-NLS-1$
-
-                    for ( Iterator<String> it = exclusions.iterator(); it.hasNext(); )
-                    {
-                        sb.append( " " + it.next() ); //$NON-NLS-1$
-
-                        if ( it.hasNext() )
-                        {
-                            sb.append( "," ); //$NON-NLS-1$
-                        }
-                    }
-
-                    sb.append( " }," ); //$NON-NLS-1$
-                }
-
-                // Removing the last ','
-                if ( sb.charAt( sb.length() - 1 ) == ',' )
-                {
-                    sb.deleteCharAt( sb.length() - 1 );
-                }
-
-                sb.append( " }" ); //$NON-NLS-1$
-
-                setValue( sb.toString() );
-
+                setValue( dialog.getSubtreeSpecificationValue() );
                 return true;
             }
         }
@@ -152,461 +88,36 @@
     /* (non-Javadoc)
      * @see org.apache.directory.ldapstudio.valueeditors.AbstractDialogStringValueEditor#getRawValue(org.apache.directory.ldapstudio.browser.core.model.IConnection, java.lang.Object)
      */
-    public Object getRawValue( IConnection connection, Object value )
+    public Object getRawValue( IValue value )
     {
-        Object o = super.getRawValue( connection, value );
+        Object o = super.getRawValue( value );
         if ( o != null && o instanceof String )
         {
-            SubtreeSpecificationParser parser = new SubtreeSpecificationParser( null );
-            try
-            {
-                SubtreeSpecification subtreeSpecification = parser.parse( ( String ) value );
-                if ( subtreeSpecification != null )
-                {
-                    return new SubtreeSpecificationValueWrapper( connection, subtreeSpecification );
-                }
-                else
-                {
-                    return new SubtreeSpecificationValueWrapper( connection, new BaseSubtreeSpecification() );
-                }
-            }
-            catch ( ParseException e1 )
-            {
-                return new SubtreeSpecificationValueWrapper( connection, null );
-            }
+            IConnection connection = value.getAttribute().getEntry().getConnection();
+            DN dn = value.getAttribute().getEntry().getDn();
+            return new SubtreeSpecificationValueWrapper( connection, dn, value.getStringValue() );
         }
 
         return null;
     }
 
-    /**
-     * This class provides a dialog to enter the Subtree Specification value.
-     *
-     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
-     * @version $Rev$, $Date$
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.ldapstudio.valueeditors.AbstractDialogStringValueEditor#getRawValue(org.apache.directory.ldapstudio.browser.core.model.IConnection, java.lang.Object)
      */
-    private class SubtreeSpecificationDialog extends Dialog
+    public Object getRawValue( IConnection connection, Object value )
     {
-        /** The connection */
-        private IConnection connection;
-
-        /** The SubtreeSpecification */
-        private SubtreeSpecification subtreeSpecification;
-
-        private int initialMaximum = 0;
-        private int initialMinimum = 0;
-
-        /** The return Base */
-        private String returnBase;
-
-        /** The return Minimum */
-        private int returnMinimum;
-
-        /** The return Maximum */
-        private int returnMaximum;
-
-        /** The Exclusions List */
-        private List<String> exclusions;
-
-        // UI Fields
-        private EntryWidget entryWidget;
-        private Spinner minimumSpinner;
-        private Spinner maximumSpinner;
-        private TableViewer exclusionsTableViewer;
-        private Button exclusionsTableAddButton;
-        private Button exclusionsTableEditButton;
-        private Button exclusionsTableDeleteButton;
-
-
-        /**
-         * Creates a new instance of SubtreeSpecificationDialog.
-         *
-         * @param shell
-         *      the shell to use
-         * @param connection
-         *      the connection to use
-         * @param subtreeSpecification
-         *      the SubtreeSpecification
-         */
-        private SubtreeSpecificationDialog( Shell shell, IConnection connection,
-            SubtreeSpecification subtreeSpecification )
-        {
-            super( shell );
-            this.connection = connection;
-            this.subtreeSpecification = subtreeSpecification;
-            exclusions = new ArrayList<String>();
-            if ( subtreeSpecification != null )
-            {
-                Set chopBeforeExclusions = subtreeSpecification.getChopBeforeExclusions();
-                for ( Object chopBeforeExclusion : chopBeforeExclusions )
-                {
-                    LdapDN dn = ( LdapDN ) chopBeforeExclusion;
-                    exclusions.add( "chopBefore: \"" + dn.toNormName() + "\"" ); //$NON-NLS-1$ //$NON-NLS-2$
-                }
-
-                Set chopAfterExclusions = subtreeSpecification.getChopAfterExclusions();
-                for ( Object chopAfterExclusion : chopAfterExclusions )
-                {
-                    LdapDN dn = ( LdapDN ) chopAfterExclusion;
-                    exclusions.add( "chopAfter: \"" + dn.toNormName() + "\"" ); //$NON-NLS-1$ //$NON-NLS-2$
-                }
-            }
-        }
-
-
-        /* (non-Javadoc)
-         * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
-         */
-        protected void configureShell( Shell newShell )
-        {
-            super.configureShell( newShell );
-            newShell.setText( Messages.getString( "SubtreeValueEditor.title" ) ); //$NON-NLS-1$
-            newShell.setImage( Activator.getDefault().getImage( Messages.getString( "SubtreeValueEditor.icon" ) ) ); //$NON-NLS-1$
-        }
-
-
-        /* (non-Javadoc)
-         * @see org.eclipse.jface.dialogs.Dialog#okPressed()
-         */
-        protected void okPressed()
-        {
-            returnBase = entryWidget.getDn().toString();
-            returnMinimum = minimumSpinner.getSelection();
-            returnMaximum = maximumSpinner.getSelection();
-            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( "SubtreeValueEditor.label.base" ), 1 ); //$NON-NLS-1$
-            entryWidget = new EntryWidget( connection, null );
-            entryWidget.createWidget( composite );
-
-            GridData spinnersGridData = new GridData();
-            spinnersGridData.grabExcessHorizontalSpace = true;
-            spinnersGridData.verticalAlignment = GridData.CENTER;
-            spinnersGridData.horizontalSpan = 2;
-            spinnersGridData.horizontalAlignment = GridData.BEGINNING;
-            spinnersGridData.widthHint = 3 * 12;
-
-            BaseWidgetUtils.createLabel( composite, Messages.getString( "SubtreeValueEditor.label.minimum" ), 1 ); //$NON-NLS-1$
-            minimumSpinner = new Spinner( composite, SWT.BORDER );
-            minimumSpinner.setMinimum( 0 );
-            minimumSpinner.setMaximum( Integer.MAX_VALUE );
-            minimumSpinner.setDigits( 0 );
-            minimumSpinner.setIncrement( 1 );
-            minimumSpinner.setPageIncrement( 100 );
-            minimumSpinner.setSelection( initialMinimum );
-            minimumSpinner.setLayoutData( spinnersGridData );
-
-            BaseWidgetUtils.createLabel( composite, Messages.getString( "SubtreeValueEditor.label.maximum" ), 1 ); //$NON-NLS-1$
-            maximumSpinner = new Spinner( composite, SWT.BORDER );
-            maximumSpinner.setMinimum( 0 );
-            maximumSpinner.setMaximum( Integer.MAX_VALUE );
-            maximumSpinner.setDigits( 0 );
-            maximumSpinner.setIncrement( 1 );
-            maximumSpinner.setPageIncrement( 100 );
-            maximumSpinner.setSelection( initialMaximum );
-            maximumSpinner.setLayoutData( spinnersGridData );
-
-            createExclusionsTable( composite );
-
-            applyDialogFont( composite );
-
-            initFromInput();
-
-            return composite;
-        }
-
-
-        /**
-         * Initializes the Value Editor from the input.
-         */
-        private void initFromInput()
-        {
-            DN dn = null;
-            try
-            {
-                dn = new DN( subtreeSpecification.getBase().toNormName() );
-            }
-            catch ( NameException e )
-            {
-                // TODO Auto-generated catch block
-                e.printStackTrace();
-            }
-            entryWidget.setInput( connection, dn );
-            minimumSpinner.setSelection( subtreeSpecification.getMinBaseDistance() );
-            maximumSpinner.setSelection( subtreeSpecification.getMaxBaseDistance() );
-            exclusionsTableViewer.setInput( exclusions );
-        }
-
-
-        /**
-         * Creates the Exclusions Table.
-         *
-         * @param composite
-         *      the composite
-         */
-        private void createExclusionsTable( Composite composite )
-        {
-            GridData tableGridData = new GridData();
-            tableGridData.grabExcessHorizontalSpace = true;
-            tableGridData.verticalAlignment = GridData.FILL;
-            tableGridData.horizontalAlignment = GridData.FILL;
-            tableGridData.heightHint = 100;
-
-            BaseWidgetUtils.createLabel( composite, Messages.getString( "SubtreeValueEditor.label.exclusions" ), 1 ); //$NON-NLS-1$
-            Table exclusionsTable = new Table( composite, SWT.BORDER );
-            exclusionsTable.setHeaderVisible( false );
-            exclusionsTable.setLayoutData( tableGridData );
-            exclusionsTable.setLinesVisible( false );
-            exclusionsTableViewer = new TableViewer( exclusionsTable );
-            exclusionsTableViewer.setContentProvider( new ArrayContentProvider() );
-            exclusionsTableViewer.setLabelProvider( new LabelProvider() );
-            exclusionsTableViewer.addSelectionChangedListener( new ISelectionChangedListener()
-            {
-                public void selectionChanged( SelectionChangedEvent event )
-                {
-                    valueSelectedExclusionsTable();
-                }
-            } );
-            exclusionsTableViewer.addDoubleClickListener( new IDoubleClickListener()
-            {
-                public void doubleClick( DoubleClickEvent event )
-                {
-                    editValueExclusionsTable();
-                }
-            } );
-
-            GridLayout gridLayout = new GridLayout();
-            gridLayout.marginWidth = 0;
-            gridLayout.marginHeight = 0;
-            GridData gridData = new GridData();
-            gridData.horizontalAlignment = GridData.CENTER;
-            gridData.grabExcessHorizontalSpace = false;
-            gridData.grabExcessVerticalSpace = false;
-            gridData.verticalAlignment = GridData.FILL;
-
-            Composite buttonComposite = new Composite( composite, SWT.NONE );
-            buttonComposite.setLayoutData( gridData );
-            buttonComposite.setLayout( gridLayout );
-
-            GridData buttonGridData = new GridData();
-            buttonGridData.horizontalAlignment = GridData.FILL;
-            buttonGridData.grabExcessHorizontalSpace = false;
-            buttonGridData.verticalAlignment = GridData.BEGINNING;
-            buttonGridData.widthHint = Activator.getButtonWidth( composite );
-
-            exclusionsTableAddButton = new Button( buttonComposite, SWT.PUSH );
-            exclusionsTableAddButton.setText( Messages.getString( "SubtreeValueEditor.button.add" ) ); //$NON-NLS-1$
-            exclusionsTableAddButton.setLayoutData( buttonGridData );
-            exclusionsTableAddButton.addSelectionListener( new SelectionAdapter()
-            {
-                public void widgetSelected( SelectionEvent e )
-                {
-                    addValueExclusionsTable();
-                }
-            } );
-
-            exclusionsTableEditButton = new Button( buttonComposite, SWT.PUSH );
-            exclusionsTableEditButton.setText( Messages.getString( "SubtreeValueEditor.button.edit" ) ); //$NON-NLS-1$
-            exclusionsTableEditButton.setLayoutData( buttonGridData );
-            exclusionsTableEditButton.addSelectionListener( new SelectionAdapter()
-            {
-                public void widgetSelected( SelectionEvent e )
-                {
-                    editValueExclusionsTable();
-                }
-            } );
-            exclusionsTableEditButton.setEnabled( false );
-
-            exclusionsTableDeleteButton = new Button( buttonComposite, SWT.PUSH );
-            exclusionsTableDeleteButton.setText( Messages.getString( "SubtreeValueEditor.button.delete" ) ); //$NON-NLS-1$
-            exclusionsTableDeleteButton.setLayoutData( buttonGridData );
-            exclusionsTableDeleteButton.addSelectionListener( new SelectionAdapter()
-            {
-                public void widgetSelected( SelectionEvent e )
-                {
-                    deleteValueExclusionsTable();
-                }
-            } );
-            exclusionsTableDeleteButton.setEnabled( false );
-        }
-
-
-        /**
-         * Called when value is selected in Exclusions table viewer.
-         * Updates the enabled/disabled state of the buttons.
-         */
-        private void valueSelectedExclusionsTable()
-        {
-            String value = getSelectedValueExclusionsTable();
-
-            if ( value == null )
-            {
-                exclusionsTableEditButton.setEnabled( false );
-                exclusionsTableDeleteButton.setEnabled( false );
-            }
-            else
-            {
-                exclusionsTableEditButton.setEnabled( true );
-                exclusionsTableDeleteButton.setEnabled( true );
-            }
-        }
-
-
-        /**
-         * Retuns the current selection in the Exclusions table viewer.
-         * 
-         * @return
-         *      the value that is selected in the Exclusions table viewer, or null.
-         */
-        private String getSelectedValueExclusionsTable()
-        {
-            String value = null;
-
-            IStructuredSelection selection = ( IStructuredSelection ) exclusionsTableViewer.getSelection();
-            if ( !selection.isEmpty() )
-            {
-                Object element = selection.getFirstElement();
-                if ( element instanceof String )
-                {
-                    value = ( String ) element;
-                }
-            }
-
-            return value;
-        }
-
-
-        /**
-         * Opens the editor and adds the new Exclusion value to the list.
-         */
-        private void addValueExclusionsTable()
-        {
-            ExclusionValueEditor valueEditor = new ExclusionValueEditor();
-
-            Object oldRawValue = valueEditor.getRawValue( connection, "" ); //$NON-NLS-1$
-
-            CellEditor cellEditor = valueEditor.getCellEditor();
-            cellEditor.setValue( oldRawValue );
-            cellEditor.activate();
-            Object newRawValue = cellEditor.getValue();
-
-            if ( newRawValue != null )
-            {
-                String newValue = ( String ) valueEditor.getStringOrBinaryValue( newRawValue );
-
-                exclusions.add( newValue );
-                exclusionsTableViewer.refresh();
-            }
-        }
-
-
-        /**
-         * Opens the editor with the currently selected Exclusion
-         * value and puts the modified value into the list.
-         */
-        private void editValueExclusionsTable()
-        {
-            ExclusionValueEditor valueEditor = new ExclusionValueEditor();
-
-            String oldValue = getSelectedValueExclusionsTable();
-            if ( oldValue != null )
-            {
-                Object oldRawValue = valueEditor.getRawValue( connection, oldValue );
-
-                CellEditor cellEditor = valueEditor.getCellEditor();
-                cellEditor.setValue( oldRawValue );
-                cellEditor.activate();
-                Object newRawValue = cellEditor.getValue();
-
-                if ( newRawValue != null )
-                {
-                    String newValue = ( String ) valueEditor.getStringOrBinaryValue( newRawValue );
-
-                    exclusions.remove( oldValue );
-                    exclusions.add( newValue );
-                    exclusionsTableViewer.refresh();
-                }
-            }
-        }
-
-
-        /**
-         * Deletes the currently selected Exclusion value from list.
-         */
-        private void deleteValueExclusionsTable()
-        {
-            String value = getSelectedValueExclusionsTable();
-            if ( value != null )
-            {
-                exclusions.remove( value );
-                exclusionsTableViewer.refresh();
-            }
-        }
-
-
-        /**
-         * Gets the Base value.
-         *
-         * @return
-         *      the base
-         */
-        public String getBase()
-        {
-            return returnBase;
-        }
-
-
-        /**
-         * Gets the Minimum Value.
-         *
-         * @return
-         *      the miminum
-         */
-        public int getMinimum()
-        {
-            return returnMinimum;
-        }
-
-
-        /**
-         * Gets the Maximum value.
-         *
-         * @return
-         *      the maximum
-         */
-        public int getMaximum()
+        Object o = super.getRawValue( connection, value );
+        if ( o != null && o instanceof String )
         {
-            return returnMaximum;
+            return new SubtreeSpecificationValueWrapper( connection, null, ( String ) value );
         }
 
-
-        /**
-         * Gets the List of Eclusions.
-         *
-         * @return
-         *      the list of exclusions
-         */
-        public List<String> getExclusions()
-        {
-            return exclusions;
-        }
+        return null;
     }
 
     /**
-     * The SubtreeSpecificationValueWrapper is used to pass contextual 
+     * The SubtreeSpecificationValueWrapper is used to pass contextual
      * information to the opened SubtreeSpecificationDialog.
      *
      * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -617,8 +128,11 @@
         /** The connection, used in DnDialog to browse for an entry */
         private IConnection connection;
 
+        /** The subentry's DN */
+        private DN subentryDN;
+
         /** The subtreeSpecification */
-        private SubtreeSpecification subtreeSpecification;
+        private String subtreeSpecification;
 
 
         /**
@@ -626,13 +140,26 @@
          *
          * @param connection
          *      the connection
-         * @param dn
-         *      the DN
+         * @param subentryDn
+         *      the DN of the subentry
+         * @param subtreeSpecification
+         *      the subtreeSpecification
          */
-        private SubtreeSpecificationValueWrapper( IConnection connection, SubtreeSpecification subtreeSpecification )
+        private SubtreeSpecificationValueWrapper( IConnection connection, DN subentryDN, String subtreeSpecification )
         {
             this.connection = connection;
+            this.subentryDN = subentryDN;
             this.subtreeSpecification = subtreeSpecification;
         }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public String toString()
+        {
+            return subtreeSpecification == null ? "" : subtreeSpecification; //$NON-NLS-1$
+        }
+
     }
 }

Modified: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/resources/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/messages.properties
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/resources/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/messages.properties?view=diff&rev=531576&r1=531575&r2=531576
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/resources/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/messages.properties (original)
+++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/resources/org/apache/directory/ldapstudio/aciitemeditor/valueeditors/messages.properties Mon Apr 23 12:55:06 2007
@@ -6,6 +6,7 @@
 SubtreeValueEditor.label.minimum=Minimum:
 SubtreeValueEditor.label.maximum=Maximum:
 SubtreeValueEditor.label.exclusions=Exclusions:
+SubtreeValueEditor.SubtreeValueEditor.label.filter=Filter
 SubtreeValueEditor.button.add=Add...
 SubtreeValueEditor.button.edit=Edit...
 SubtreeValueEditor.button.delete=Delete
@@ -20,3 +21,5 @@
 AttributeTypeAndValueDialog.title=Attribute Type and Value Editor
 AttributeTypeAndValueDialog.icon=resources/icons/attributetypeeditor.png
 AttributeTypeDialog.icon=resources/icons/attributetypeeditor.png
+SubtreeValueEditor.SubtreeValueEditor.label.refinementOrFilter=Refinement or Filter:
+SubtreeValueEditor.SubtreeValueEditor.label.refinement=Refinement



Mime
View raw message