Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 64974 invoked from network); 3 Apr 2007 16:31:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Apr 2007 16:31:02 -0000 Received: (qmail 51509 invoked by uid 500); 3 Apr 2007 16:31:09 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 51480 invoked by uid 500); 3 Apr 2007 16:31:09 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 51469 invoked by uid 99); 3 Apr 2007 16:31:09 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Apr 2007 09:31:09 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Apr 2007 09:31:01 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 5D8D01A983E; Tue, 3 Apr 2007 09:30:40 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r525202 - in /directory/ldapstudio/trunk: ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ ldapstudio-browser... Date: Tue, 03 Apr 2007 16:30:39 -0000 To: commits@directory.apache.org From: pamarcelot@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070403163040.5D8D01A983E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pamarcelot Date: Tue Apr 3 09:30:37 2007 New Revision: 525202 URL: http://svn.apache.org/viewvc?view=rev&rev=525202 Log: Updated the SubtreeSpecification Value Editor and the Exclusion Value Editor. updated exported pacakges in the ldapstudio-browser-ui project. 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 directory/ldapstudio/trunk/ldapstudio-browser-ui/META-INF/MANIFEST.MF 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=525202&r1=525201&r2=525202 ============================================================================== --- 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 Tue Apr 3 09:30:37 2007 @@ -23,9 +23,13 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +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.ui.dialogs.TextDialog; import org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogStringValueEditor; import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils; +import org.apache.directory.ldapstudio.browser.ui.widgets.search.EntryWidget; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.viewers.ArrayContentProvider; @@ -42,35 +46,35 @@ /** - * TODO ExclusionValueEditor. + * ACI item editor specific value editor to edit an Exclusion. * * @author Apache Directory Project * @version $Rev$, $Date$ */ public class ExclusionValueEditor extends AbstractDialogStringValueEditor { - /* (non-Javadoc) * @see org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogValueEditor#openDialog(org.eclipse.swt.widgets.Shell) */ - @Override protected boolean openDialog( Shell shell ) { Object value = getValue(); if ( value != null && value instanceof ExclusionWrapper ) { - ExclusionWrapper wrapper = ( ExclusionWrapper ) value; - ExclusionDialog dialog = new ExclusionDialog( shell, wrapper.type, null ); - dialog.open(); + ExclusionDialog dialog = new ExclusionDialog( shell, ( ExclusionWrapper ) value ); + if ( dialog.open() == TextDialog.OK && !"".equals( dialog.getType() ) && !"".equals( dialog.getRDN() ) ) + { + setValue( dialog.getType() + ": \"" + dialog.getRDN() + "\"" ); + return true; + } } + return false; } - /** - * {@inheritDoc} - * - * Returns an MaxValueCountValueEditorRawValueWrapper. + /* (non-Javadoc) + * @see org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogStringValueEditor#getRawValue(org.apache.directory.ldapstudio.browser.core.model.IConnection, java.lang.Object) */ public Object getRawValue( IConnection connection, Object value ) { @@ -85,7 +89,7 @@ try { // for example: chopAfter: "ou=A" - Pattern pattern = Pattern.compile( "\\s*([chopBefore|chopAfter]):\\s*\"(.*)\"\\s*" ); + 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 ) : ""; @@ -94,19 +98,21 @@ { } - ExclusionWrapper wrapper = new ExclusionWrapper( type, rdn ); + ExclusionWrapper wrapper = new ExclusionWrapper( connection, type, rdn ); return wrapper; } /** - * The ExclusionWrapper is used to pass contextual - * information to the opened ExclusionDialog. + * The ExclusionWrapper is used to pass contextual information to the opened ExclusionDialog. * * @author Apache Directory Project * @version $Rev$, $Date$ */ private class ExclusionWrapper { + /** The connection */ + private IConnection connection; + /** The type, used as initial type. */ private String type; @@ -122,15 +128,16 @@ * @param rdn * the rdn */ - private ExclusionWrapper( String type, String rdn ) + private ExclusionWrapper( IConnection connection, String type, String rdn ) { + this.connection = connection; this.type = type; this.rdn = rdn; } } /** - * TODO ExclusionDialog. + * This class provides a dialog to enter the Exclusion values. * * @author Apache Directory Project * @version $Rev$, $Date$ @@ -140,12 +147,6 @@ /** The dialog title */ public static final String DIALOG_TITLE = "Exclusion Editor"; - /** The initial type */ - private String initialType; - - /** The initial RDN */ - private String initialRDN; - /** The return type */ private String returnType; @@ -154,6 +155,12 @@ private Combo typeCombo; + private ExclusionWrapper wrapper; + + private ComboViewer typeComboViewer; + + private EntryWidget entryWidget; + private static final String CHOP_BEFORE = "chopBefore"; private static final String CHOP_AFTER = "chopAfter"; @@ -164,11 +171,10 @@ * * @param parentShell */ - protected ExclusionDialog( Shell parentShell, String initialType, String initialRDN ) + protected ExclusionDialog( Shell parentShell, ExclusionWrapper wrapper ) { super( parentShell ); - this.initialType = initialType; - this.initialRDN = initialRDN; + this.wrapper = wrapper; } @@ -182,13 +188,13 @@ } - /** - * {@inheritDoc} + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#okPressed() */ protected void okPressed() { returnType = typeCombo.getText(); - // initialRDN = rdnFields.getSelection(); + returnRDN = entryWidget.getDn().toString(); super.okPressed(); } @@ -202,22 +208,51 @@ GridData gd = new GridData( GridData.FILL_BOTH ); gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ); composite.setLayoutData( gd ); - composite.setLayout( new GridLayout( 2, false ) ); + composite.setLayout( new GridLayout( 3, false ) ); BaseWidgetUtils.createLabel( composite, "Type:", 1 ); - typeCombo = new Combo( composite, SWT.NONE ); + typeCombo = new Combo( composite, SWT.READ_ONLY ); String[] types = new String[2]; types[0] = CHOP_BEFORE; types[1] = CHOP_AFTER; - ComboViewer typeComboViewer = new ComboViewer( typeCombo ); + typeComboViewer = new ComboViewer( typeCombo ); typeComboViewer.setContentProvider( new ArrayContentProvider() ); typeComboViewer.setLabelProvider( new LabelProvider() ); typeComboViewer.setInput( types ); - typeComboViewer.setSelection( new StructuredSelection( initialType ) ); + GridData gridData = new GridData(); + gridData.horizontalSpan = 2; + gridData.grabExcessHorizontalSpace = true; + gridData.verticalAlignment = GridData.CENTER; + gridData.horizontalAlignment = GridData.BEGINNING; + typeCombo.setLayoutData( gridData ); + + BaseWidgetUtils.createLabel( composite, "RDN:", 1 ); + entryWidget = new EntryWidget( wrapper.connection, null ); + entryWidget.createWidget( composite ); - BaseWidgetUtils.createLabel( composite, "RDN:", 2 ); + initFromInput(); return composite; + } + + + /** + * Initializes the Value Editor from the input. + */ + private void initFromInput() + { + typeComboViewer.setSelection( new StructuredSelection( wrapper.type ) ); + + try + { + DN dn = new DN( wrapper.rdn ); + entryWidget.setInput( wrapper.connection, dn ); + } + catch ( NameException e ) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } } 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=525202&r1=525201&r2=525202 ============================================================================== --- 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 Tue Apr 3 09:30:37 2007 @@ -20,12 +20,23 @@ package org.apache.directory.ldapstudio.aciitemeditor.widgets; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + import org.apache.directory.ldapstudio.aciitemeditor.Activator; import org.apache.directory.ldapstudio.aciitemeditor.ExclusionValueEditor; -import org.apache.directory.ldapstudio.browser.core.model.IValue; +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.ui.dialogs.TextDialog; import org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogStringValueEditor; import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils; +import org.apache.directory.ldapstudio.browser.ui.widgets.search.EntryWidget; +import org.apache.directory.shared.ldap.name.LdapDN; +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; @@ -51,7 +62,7 @@ /** - * TODO SubtreeSpecificationValueEditor. + * ACI item editor specific value editor to edit the SubtreeSpecification. * * @author Apache Directory Project * @version $Rev$, $Date$ @@ -63,56 +74,116 @@ */ protected boolean openDialog( Shell shell ) { - SubtreeDialog dialog = new SubtreeDialog( shell ); - if ( dialog.open() == TextDialog.OK ) + Object value = getValue(); + if ( value != null && value instanceof SubtreeSpecificationValueWrapper ) { - return true; + SubtreeSpecificationValueWrapper wrapper = ( SubtreeSpecificationValueWrapper ) value; + SubtreeSpecificationDialog dialog = new SubtreeSpecificationDialog( shell, wrapper.connection, + wrapper.subtreeSpecification ); + if ( dialog.open() == TextDialog.OK ) + { + return true; + } } - return false; } + + /* (non-Javadoc) + * @see org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogStringValueEditor#getRawValue(org.apache.directory.ldapstudio.browser.core.model.IConnection, java.lang.Object) + */ + public Object getRawValue( IConnection connection, Object value ) + { + Object o = super.getRawValue( connection, 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 ); + } + } + catch ( ParseException e1 ) + { + return new SubtreeSpecificationValueWrapper( connection, null ); + } + } + + return null; + } + /** - * TODO SubtreeDialog. + * This class provides a dialog to enter the Subtree Specification value. * * @author Apache Directory Project * @version $Rev$, $Date$ */ - private class SubtreeDialog extends Dialog + private class SubtreeSpecificationDialog extends Dialog { /** The dialog title */ - public static final String DIALOG_TITLE = "Subtree Editor"; + private static final String DIALOG_TITLE = "Subtree Editor"; + + /** The connection */ + private IConnection connection; + + /** The SubtreeSpecification */ + private SubtreeSpecification subtreeSpecification; + /** The Exclusions List */ + private List 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; - private Button exclusionsTableDeleteButton; - private TableViewer refinementsTableViewer; - private Button refinementsTableAddButton; - private Button refinementsTableEditButton; - private Button refinementsTableDeleteButton; /** - * Creates a new instance of SubtreeDialog. + * Creates a new instance of SubtreeSpecificationDialog. * - * @param parentShell + * @param shell + * the shell to use + * @param connection + * the connection to use + * @param subtreeSpecification + * the SubtreeSpecification */ - protected SubtreeDialog( Shell parentShell ) + private SubtreeSpecificationDialog( Shell shell, IConnection connection, + SubtreeSpecification subtreeSpecification ) { - super( parentShell ); + super( shell ); + this.connection = connection; + this.subtreeSpecification = subtreeSpecification; + exclusions = new ArrayList(); + if ( subtreeSpecification != null ) + { + Set chopBeforeExclusions = subtreeSpecification.getChopBeforeExclusions(); + for ( Object chopBeforeExclusion : chopBeforeExclusions ) + { + LdapDN dn = ( LdapDN ) chopBeforeExclusion; + exclusions.add( "chopBefore: \"" + dn.toNormName() + "\"" ); + } + + Set chopAfterExclusions = subtreeSpecification.getChopAfterExclusions(); + for ( Object chopAfterExclusion : chopAfterExclusions ) + { + LdapDN dn = ( LdapDN ) chopAfterExclusion; + exclusions.add( "chopAfter: \"" + dn.toNormName() + "\"" ); + } + } } @@ -137,7 +208,9 @@ composite.setLayoutData( gd ); composite.setLayout( new GridLayout( 3, false ) ); - BaseWidgetUtils.createLabel( composite, "Base:", 3 ); + BaseWidgetUtils.createLabel( composite, "Base:", 1 ); + entryWidget = new EntryWidget( connection, null ); + entryWidget.createWidget( composite ); GridData spinnersGridData = new GridData(); spinnersGridData.grabExcessHorizontalSpace = true; @@ -171,10 +244,43 @@ createRefinementsTable( 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(); @@ -191,8 +297,6 @@ exclusionsTableViewer = new TableViewer( exclusionsTable ); exclusionsTableViewer.setContentProvider( new ArrayContentProvider() ); exclusionsTableViewer.setLabelProvider( new LabelProvider() ); - exclusionsTableViewer.setInput( new String[] - { "chopBefore: \"ou=A\"", "chopAfter: \"ou=A\"" } ); exclusionsTableViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged( SelectionChangedEvent event ) @@ -265,8 +369,8 @@ /** - * TODO valueSelectedExclusionsTable. - * + * Called when value is selected in Exclusions table viewer. + * Updates the enabled/disabled state of the buttons. */ private void valueSelectedExclusionsTable() { @@ -286,9 +390,10 @@ /** - * TODO getSelectedValue. - * + * 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() { @@ -309,59 +414,70 @@ /** - * TODO addValueExclusionsTable. - * + * Opens the editor and adds the new Exclusion value to the list. */ private void addValueExclusionsTable() { ExclusionValueEditor valueEditor = new ExclusionValueEditor(); - Object oldRawValue = valueEditor.getRawValue( null, "" ); + Object oldRawValue = valueEditor.getRawValue( connection, "" ); 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(); + } } /** - * TODO editValueExclusionsTable. - * + * 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( null, oldValue ); - + Object oldRawValue = valueEditor.getRawValue( connection, oldValue ); + CellEditor cellEditor = valueEditor.getCellEditor(); cellEditor.setValue( oldRawValue ); cellEditor.activate(); Object newRawValue = cellEditor.getValue(); - - if(newRawValue != null) + + if ( newRawValue != null ) { - String newValue = (String) valueEditor.getStringOrBinaryValue( newRawValue ); - -// values.remove( oldValue ); -// values.add( newValue ); -// tableViewer.refresh(); + String newValue = ( String ) valueEditor.getStringOrBinaryValue( newRawValue ); + + exclusions.remove( oldValue ); + exclusions.add( newValue ); + exclusionsTableViewer.refresh(); } } } /** - * TODO deleteValueExclusionsTable. - * + * Deletes the currently selected Exclusion value from list. */ private void deleteValueExclusionsTable() { - // TODO Auto-generated method stub - + String value = getSelectedValueExclusionsTable(); + if ( value != null ) + { + exclusions.remove( value ); + exclusionsTableViewer.refresh(); + } } @@ -381,8 +497,6 @@ refinementsTableViewer = new TableViewer( refinementsTable ); refinementsTableViewer.setContentProvider( new ArrayContentProvider() ); refinementsTableViewer.setLabelProvider( new LabelProvider() ); - refinementsTableViewer.setInput( new String[] - { "and:{ item:35.5.2.1, item:inetOrgPerson }" } ); refinementsTableViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged( SelectionChangedEvent event ) @@ -515,7 +629,40 @@ private void deleteValueRefinementsTable() { + + // TODO Auto-generated method stub } + } + + /** + * The SubtreeSpecificationValueWrapper is used to pass contextual + * information to the opened SubtreeSpecificationDialog. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ + private class SubtreeSpecificationValueWrapper + { + /** The connection, used in DnDialog to browse for an entry */ + private IConnection connection; + + /** The subtreeSpecification */ + private SubtreeSpecification subtreeSpecification; + + + /** + * Creates a new instance of SubtreeSpecificationValueWrapper. + * + * @param connection + * the connection + * @param dn + * the DN + */ + private SubtreeSpecificationValueWrapper( IConnection connection, SubtreeSpecification subtreeSpecification ) + { + this.connection = connection; + this.subtreeSpecification = subtreeSpecification; + } } } Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/META-INF/MANIFEST.MF URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/META-INF/MANIFEST.MF?view=diff&rev=525202&r1=525201&r2=525202 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-browser-ui/META-INF/MANIFEST.MF (original) +++ directory/ldapstudio/trunk/ldapstudio-browser-ui/META-INF/MANIFEST.MF Tue Apr 3 09:30:37 2007 @@ -21,4 +21,5 @@ Export-Package: org.apache.directory.ldapstudio.browser.ui.dialogs, org.apache.directory.ldapstudio.browser.ui.valueeditors, org.apache.directory.ldapstudio.browser.ui.valueeditors.internal;x-friends:="org.apache.directory.ldapstudio.aciitemeditor", - org.apache.directory.ldapstudio.browser.ui.widgets;x-friends:="org.apache.directory.ldapstudio.aciitemeditor" + org.apache.directory.ldapstudio.browser.ui.widgets;x-friends:="org.apache.directory.ldapstudio.aciitemeditor", + org.apache.directory.ldapstudio.browser.ui.widgets.search;x-friends:="org.apache.directory.ldapstudio.aciitemeditor"