directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r525484 - in /directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor: ExclusionValueEditor.java widgets/SubtreeSpecificationValueEditor.java
Date Wed, 04 Apr 2007 10:10:19 GMT
Author: pamarcelot
Date: Wed Apr  4 03:10:15 2007
New Revision: 525484

URL: http://svn.apache.org/viewvc?view=rev&rev=525484
Log:
Updated Subtree Specification Value Editor.

Modified:
    directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ExclusionValueEditor.java
    directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/SubtreeSpecificationValueEditor.java

Modified: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ExclusionValueEditor.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ExclusionValueEditor.java?view=diff&rev=525484&r1=525483&r2=525484
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ExclusionValueEditor.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ExclusionValueEditor.java
Wed Apr  4 03:10:15 2007
@@ -62,9 +62,9 @@
         if ( value != null && value instanceof ExclusionWrapper )
         {
             ExclusionDialog dialog = new ExclusionDialog( shell, ( ExclusionWrapper ) value
);
-            if ( dialog.open() == TextDialog.OK && !"".equals( dialog.getType() )
&& !"".equals( dialog.getRDN() ) )
+            if ( dialog.open() == TextDialog.OK && !"".equals( dialog.getType() )
&& !"".equals( dialog.getDN() ) )
             {
-                setValue( dialog.getType() + ": \"" + dialog.getRDN() + "\"" );
+                setValue( dialog.getType() + ": \"" + dialog.getDN() + "\"" );
                 return true;
             }
         }
@@ -85,20 +85,20 @@
 
         String stringValue = ( String ) value;
         String type = "";
-        String rdn = "";
+        String dn = "";
         try
         {
             // for example: chopAfter: "ou=A"
             Pattern pattern = Pattern.compile( "\\s*(chopBefore|chopAfter):\\s*\"(.*)\"\\s*"
);
             Matcher matcher = pattern.matcher( stringValue );
             type = matcher.matches() ? matcher.group( 1 ) : "";
-            rdn = matcher.matches() ? matcher.group( 2 ) : "";
+            dn = matcher.matches() ? matcher.group( 2 ) : "";
         }
         catch ( Exception e )
         {
         }
 
-        ExclusionWrapper wrapper = new ExclusionWrapper( connection, type, rdn );
+        ExclusionWrapper wrapper = new ExclusionWrapper( connection, type, dn );
         return wrapper;
     }
 
@@ -116,8 +116,8 @@
         /** The type, used as initial type. */
         private String type;
 
-        /** The RDN, used as initial RDN. */
-        private String rdn;
+        /** The DN, used as initial DN. */
+        private String dn;
 
 
         /**
@@ -125,14 +125,14 @@
          * 
          * @param type
          *      the type
-         * @param rdn
-         *      the rdn
+         * @param dn
+         *      the dn
          */
-        private ExclusionWrapper( IConnection connection, String type, String rdn )
+        private ExclusionWrapper( IConnection connection, String type, String dn )
         {
             this.connection = connection;
             this.type = type;
-            this.rdn = rdn;
+            this.dn = dn;
         }
     }
 
@@ -150,21 +150,20 @@
         /** The return type */
         private String returnType;
 
-        /** The return RDN */
-        private String returnRDN;
-
-        private Combo typeCombo;
+        /** The return DN */
+        private String returnDN;
 
+        /** The wrapper */
         private ExclusionWrapper wrapper;
 
-        private ComboViewer typeComboViewer;
-
-        private EntryWidget entryWidget;
-
         private static final String CHOP_BEFORE = "chopBefore";
-
         private static final String CHOP_AFTER = "chopAfter";
 
+        // UI Fields
+        private Combo typeCombo;
+        private ComboViewer typeComboViewer;
+        private EntryWidget entryWidget;
+
 
         /**
          * Creates a new instance of ExclusionDialog.
@@ -194,7 +193,7 @@
         protected void okPressed()
         {
             returnType = typeCombo.getText();
-            returnRDN = entryWidget.getDn().toString();
+            returnDN = entryWidget.getDn().toString();
             super.okPressed();
         }
 
@@ -219,6 +218,7 @@
             typeComboViewer.setContentProvider( new ArrayContentProvider() );
             typeComboViewer.setLabelProvider( new LabelProvider() );
             typeComboViewer.setInput( types );
+            typeComboViewer.setSelection( new StructuredSelection( CHOP_BEFORE ), true );
             GridData gridData = new GridData();
             gridData.horizontalSpan = 2;
             gridData.grabExcessHorizontalSpace = true;
@@ -241,11 +241,11 @@
          */
         private void initFromInput()
         {
-            typeComboViewer.setSelection( new StructuredSelection( wrapper.type ) );
+            typeComboViewer.setSelection( new StructuredSelection( wrapper.type ), true );
 
             try
             {
-                DN dn = new DN( wrapper.rdn );
+                DN dn = new DN( wrapper.dn );
                 entryWidget.setInput( wrapper.connection, dn );
             }
             catch ( NameException e )
@@ -269,14 +269,14 @@
 
 
         /**
-         * Gets the RDN.
+         * Gets the DN.
          *
          * @return
-         *      the RDN, null if canceled
+         *      the DN, null if canceled
          */
-        public String getRDN()
+        public String getDN()
         {
-            return returnRDN;
+            return returnDN;
         }
     }
 }

Modified: directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/SubtreeSpecificationValueEditor.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/SubtreeSpecificationValueEditor.java?view=diff&rev=525484&r1=525483&r2=525484
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/SubtreeSpecificationValueEditor.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/SubtreeSpecificationValueEditor.java
Wed Apr  4 03:10:15 2007
@@ -22,6 +22,7 @@
 
 import java.text.ParseException;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -82,6 +83,60 @@
                 wrapper.subtreeSpecification );
             if ( dialog.open() == TextDialog.OK )
             {
+                String base = dialog.getBase();
+                int minimum = dialog.getMinimum();
+                int maximum = dialog.getMaximum();
+                List<String> exclusions = dialog.getExclusions();
+
+                StringBuffer sb = new StringBuffer();
+                sb.append( "{" );
+
+                // Adding base
+                if ( base != null )
+                {
+                    sb.append( " base \"" + base + "\"," );
+                }
+
+                // Adding Minimum
+                if ( minimum != 0 )
+                {
+                    sb.append( " minimum " + minimum + "," );
+                }
+
+                // Adding Maximum
+                if ( maximum != 0 )
+                {
+                    sb.append( " maximum " + maximum + "," );
+                }
+
+                // Adding Exclusions
+                if ( !exclusions.isEmpty() )
+                {
+                    sb.append( " specificExclusions {" );
+
+                    for ( Iterator<String> it = exclusions.iterator(); it.hasNext();
)
+                    {
+                        sb.append( " " + it.next() );
+
+                        if ( it.hasNext() )
+                        {
+                            sb.append( "," );
+                        }
+                    }
+
+                    sb.append( " }," );
+                }
+
+                // Removing the last ','
+                if ( sb.charAt( sb.length() - 1 ) == ',' )
+                {
+                    sb.deleteCharAt( sb.length() - 1 );
+                }
+
+                sb.append( " }" );
+
+                setValue( sb.toString() );
+
                 return true;
             }
         }
@@ -132,15 +187,25 @@
         /** 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 int initialMinimum = 0;
         private Spinner maximumSpinner;
-        private int initialMaximum = 0;
         private TableViewer exclusionsTableViewer;
         private Button exclusionsTableAddButton;
         private Button exclusionsTableEditButton;
@@ -198,6 +263,18 @@
 
 
         /* (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 )
@@ -267,10 +344,8 @@
                 e.printStackTrace();
             }
             entryWidget.setInput( connection, dn );
-
             minimumSpinner.setSelection( subtreeSpecification.getMinBaseDistance() );
             maximumSpinner.setSelection( subtreeSpecification.getMaxBaseDistance() );
-
             exclusionsTableViewer.setInput( exclusions );
         }
 
@@ -633,6 +708,53 @@
             // TODO Auto-generated method stub
         }
 
+
+        /**
+         * 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()
+        {
+            return returnMaximum;
+        }
+
+
+        /**
+         * Gets the List of Eclusions.
+         *
+         * @return
+         *      the list of exclusions
+         */
+        public List<String> getExclusions()
+        {
+            return exclusions;
+        }
     }
 
     /**



Mime
View raw message