Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 28113 invoked from network); 13 Apr 2007 12:41:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Apr 2007 12:41:37 -0000 Received: (qmail 11302 invoked by uid 500); 13 Apr 2007 12:41:43 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 11255 invoked by uid 500); 13 Apr 2007 12:41:43 -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 11175 invoked by uid 99); 13 Apr 2007 12:41:43 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Apr 2007 05:41:42 -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; Fri, 13 Apr 2007 05:41:34 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id A9B1C1A9838; Fri, 13 Apr 2007 05:41:14 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r528468 - in /directory/ldapstudio/trunk/ldapstudio-apacheds-configuration: icons/ src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/ src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/actions/ src/main/... Date: Fri, 13 Apr 2007 12:41:13 -0000 To: commits@directory.apache.org From: pamarcelot@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070413124114.A9B1C1A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pamarcelot Date: Fri Apr 13 05:41:12 2007 New Revision: 528468 URL: http://svn.apache.org/viewvc?view=rev&rev=528468 Log: Updated icons. Added a special behavior for the system partition so it is not possible to delete it. Added support for Adding/Editing/Deleting values of the Context Entry. Added: directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/icons/partition_system.gif (with props) directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/dialogs/AttributeValueDialog.java directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/editor/AttributeValueObject.java Modified: directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/icons/interceptor.gif directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/icons/partition.gif directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/PluginConstants.java directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/actions/OpenEditorAction.java directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/dialogs/IndexedAttributeDialog.java directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/editor/PartitionDetailsPage.java directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/model/Partition.java Modified: directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/icons/interceptor.gif URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/icons/interceptor.gif?view=diff&rev=528468&r1=528467&r2=528468 ============================================================================== Binary files - no diff available. Modified: directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/icons/partition.gif URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/icons/partition.gif?view=diff&rev=528468&r1=528467&r2=528468 ============================================================================== Binary files - no diff available. Added: directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/icons/partition_system.gif URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/icons/partition_system.gif?view=auto&rev=528468 ============================================================================== Binary file - no diff available. Propchange: directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/icons/partition_system.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/PluginConstants.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/PluginConstants.java?view=diff&rev=528468&r1=528467&r2=528468 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/PluginConstants.java (original) +++ directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/PluginConstants.java Fri Apr 13 05:41:12 2007 @@ -19,6 +19,7 @@ */ package org.apache.directory.ldapstudio.apacheds.configuration; + /** * This interface contains all the Constants used in the Plugin. * @@ -28,8 +29,9 @@ public interface PluginConstants { public static final String IMG_VERTICAL_ORIENTATION = "icons/vertical_orientation.gif"; - public static final String IMG_HORIZONTAL_ORIENTATION = "icons/horizontal_orientation.gif"; - public static final String IMG_PARTITION = "icons/partition.gif"; - public static final String IMG_INTERCEPTOR= "icons/interceptor.gif"; - public static final String IMG_EXTENDED_OPERATION = "icons/extended_operation.gif"; + public static final String IMG_HORIZONTAL_ORIENTATION = "icons/horizontal_orientation.gif"; + public static final String IMG_PARTITION = "icons/partition.gif"; + public static final String IMG_PARTITION_SYSTEM = "icons/partition_system.gif"; + public static final String IMG_INTERCEPTOR = "icons/interceptor.gif"; + public static final String IMG_EXTENDED_OPERATION = "icons/extended_operation.gif"; } Modified: directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/actions/OpenEditorAction.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/actions/OpenEditorAction.java?view=diff&rev=528468&r1=528467&r2=528468 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/actions/OpenEditorAction.java (original) +++ directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/actions/OpenEditorAction.java Fri Apr 13 05:41:12 2007 @@ -1,6 +1,11 @@ package org.apache.directory.ldapstudio.apacheds.configuration.actions; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; + import org.apache.directory.ldapstudio.apacheds.configuration.editor.ServerConfigurationEditor; import org.apache.directory.ldapstudio.apacheds.configuration.editor.ServerConfigurationEditorInput; import org.apache.directory.ldapstudio.apacheds.configuration.model.ExtendedOperation; @@ -58,13 +63,30 @@ Partition partition = new Partition( "System Partition" ); partition.setSuffix( "ou=system" ); - // TODO Add Context Entry + Attributes attributes = new BasicAttributes( true ); + Attribute attribute = new BasicAttribute( "dc" ); + attribute.add( "example" ); + attribute.add( "com" ); + attributes.put( attribute ); + partition.setContextEntry( attributes ); partition.setEnableOptimizer( true ); partition.setCacheSize( 1000 ); partition.setSynchronizationOnWrite( true ); partition.addIndexedAttribute( new IndexedAttribute( "cn", 100 ) ); partition.addIndexedAttribute( new IndexedAttribute( "ou", 30 ) ); + partition.setSystemPartition( true ); serverConfiguration.addPartition( partition ); + + Partition partition2 = new Partition( "Example Partition" ); + partition2.setSuffix( "dc=example, dc=com" ); + // TODO Add Context Entry + partition2.setEnableOptimizer( false ); + partition2.setCacheSize( 500 ); + partition2.setSynchronizationOnWrite( false ); + partition2.addIndexedAttribute( new IndexedAttribute( "uid", 50 ) ); + partition2.addIndexedAttribute( new IndexedAttribute( "dc", 15 ) ); + partition2.setSystemPartition( false ); + serverConfiguration.addPartition( partition2 ); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try Added: directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/dialogs/AttributeValueDialog.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/dialogs/AttributeValueDialog.java?view=auto&rev=528468 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/dialogs/AttributeValueDialog.java (added) +++ directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/dialogs/AttributeValueDialog.java Fri Apr 13 05:41:12 2007 @@ -0,0 +1,176 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.ldapstudio.apacheds.configuration.dialogs; + + +import org.apache.directory.ldapstudio.apacheds.configuration.editor.AttributeValueObject; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; + + +/** + * This class implements the Dialog for Attribute Value. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class AttributeValueDialog extends Dialog +{ + /** The Attribute Value Object */ + private AttributeValueObject attributeValueObject; + + /** The dirty flag */ + private boolean dirty = false; + + // UI Fields + private Text attributeText; + private Text valueText; + + + /** + * Creates a new instance of AttributeValueDialog. + */ + public AttributeValueDialog( AttributeValueObject attributeValueObject ) + { + super( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() ); + this.attributeValueObject = attributeValueObject; + } + + + /* (non-Javadoc) + * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) + */ + protected void configureShell( Shell newShell ) + { + super.configureShell( newShell ); + newShell.setText( "Attribute Value Dialog" ); + } + + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + protected Control createDialogArea( Composite parent ) + { + Composite composite = new Composite( parent, SWT.NONE ); + GridLayout layout = new GridLayout( 2, false ); + composite.setLayout( layout ); + composite.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true ) ); + + Label attributeLabel = new Label( composite, SWT.NONE ); + attributeLabel.setText( "Attribute:" ); + + attributeText = new Text( composite, SWT.BORDER ); + attributeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); + + Label valueLabel = new Label( composite, SWT.NONE ); + valueLabel.setText( "Value:" ); + + valueText = new Text( composite, SWT.BORDER ); + valueText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); + + initFromInput(); + addListeners(); + + return composite; + } + + + /** + * Initializes the UI from the input. + */ + private void initFromInput() + { + String attribute = attributeValueObject.getAttribute(); + attributeText.setText( ( attribute == null ) ? "" : attribute ); + + Object value = attributeValueObject.getValue(); + valueText.setText( ( value == null ) ? "" : value.toString() ); + } + + + /** + * Adds listeners to the UI Fields. + */ + private void addListeners() + { + attributeText.addModifyListener( new ModifyListener() + { + public void modifyText( ModifyEvent e ) + { + dirty = true; + } + } ); + + valueText.addModifyListener( new ModifyListener() + { + public void modifyText( ModifyEvent e ) + { + dirty = true; + } + } ); + } + + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ + protected void okPressed() + { + attributeValueObject.setId( attributeText.getText() ); + attributeValueObject.setValue( valueText.getText() ); + + super.okPressed(); + } + + + /** + * Gets the Attribute Value Object. + * + * @return + * the Attribute Value Object + */ + public AttributeValueObject getAttributeValueObject() + { + return attributeValueObject; + } + + + /** + * Returns the dirty flag of the dialog. + * + * @return + * the dirty flag of the dialog + */ + public boolean isDirty() + { + return dirty; + } +} Modified: directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/dialogs/IndexedAttributeDialog.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/dialogs/IndexedAttributeDialog.java?view=diff&rev=528468&r1=528467&r2=528468 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/dialogs/IndexedAttributeDialog.java (original) +++ directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/dialogs/IndexedAttributeDialog.java Fri Apr 13 05:41:12 2007 @@ -72,7 +72,7 @@ protected void configureShell( Shell newShell ) { super.configureShell( newShell ); - newShell.setText( "Indexed Attribute" ); + newShell.setText( "Indexed Attribute Dialog" ); } Added: directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/editor/AttributeValueObject.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/editor/AttributeValueObject.java?view=auto&rev=528468 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/editor/AttributeValueObject.java (added) +++ directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/editor/AttributeValueObject.java Fri Apr 13 05:41:12 2007 @@ -0,0 +1,108 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.ldapstudio.apacheds.configuration.editor; + + +/** + * This class implements an Attribute Value Object that is used in the PartitionDetailsPage. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class AttributeValueObject +{ + /** The attribute */ + private String attribute; + + /** The value */ + private Object value; + + + /** + * Creates a new instance of AttributeValueObject. + * + * @param attribute + * the attribute + * @param value + * the value + */ + public AttributeValueObject( String attribute, Object value ) + { + this.attribute = attribute; + this.value = value; + } + + + /** + * Gets the attribute. + * + * @return + * the attribute. + */ + public String getAttribute() + { + return attribute; + } + + + /** + * Sets the attribute. + * + * @param attribute + * the new attribute + */ + public void setId( String attribute ) + { + this.attribute = attribute; + } + + + /** + * Gets the value. + * + * @return + * the value + */ + public Object getValue() + { + return value; + } + + + /** + * Sets the value. + * + * @param value + * the new value + */ + public void setValue( Object value ) + { + this.value = value; + } + + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + public String toString() + { + return "Attribute=\"" + attribute + "\", Value=\"" + value + "\""; + } +} Modified: directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/editor/PartitionDetailsPage.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/editor/PartitionDetailsPage.java?view=diff&rev=528468&r1=528467&r2=528468 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/editor/PartitionDetailsPage.java (original) +++ directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/editor/PartitionDetailsPage.java Fri Apr 13 05:41:12 2007 @@ -20,8 +20,16 @@ package org.apache.directory.ldapstudio.apacheds.configuration.editor; +import java.util.ArrayList; import java.util.List; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; + +import org.apache.directory.ldapstudio.apacheds.configuration.dialogs.AttributeValueDialog; import org.apache.directory.ldapstudio.apacheds.configuration.dialogs.IndexedAttributeDialog; import org.apache.directory.ldapstudio.apacheds.configuration.model.IndexedAttribute; import org.apache.directory.ldapstudio.apacheds.configuration.model.Partition; @@ -30,13 +38,17 @@ import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -45,11 +57,13 @@ import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.events.VerifyEvent; import org.eclipse.swt.events.VerifyListener; +import org.eclipse.swt.graphics.Image; 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.Table; +import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.IDetailsPage; import org.eclipse.ui.forms.IFormPart; @@ -77,6 +91,9 @@ /** The input Partition */ private Partition input; + /** The Context Entry */ + private Attributes contextEntry; + /** The Indexed Attributes List */ private List indexedAttributes; @@ -86,6 +103,7 @@ private Text suffixText; private Button enableOptimizerCheckbox; private Button synchOnWriteCheckbox; + private Table contextEntryTable; private TableViewer contextEntryTableViewer; private Button contextEntryAddButton; private Button contextEntryEditButton; @@ -124,12 +142,39 @@ } }; + /** The Double Click Listener for the Indexed Attributes Table Viewer */ + private IDoubleClickListener contextEntryTableViewerDoubleClickListener = new IDoubleClickListener() + { + public void doubleClick( DoubleClickEvent event ) + { + editSelectedContextEntry(); + } + }; + /** The Listener for the Add button of the Context Entry Section */ private SelectionListener contextEntryAddButtonListener = new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { - masterDetailsBlock.setEditorDirty(); + AttributeValueDialog dialog = new AttributeValueDialog( new AttributeValueObject( "", "" ) ); + if ( Dialog.OK == dialog.open() && dialog.isDirty() ) + { + AttributeValueObject newAttributeValueObject = dialog.getAttributeValueObject(); + Attribute attribute = contextEntry.get( newAttributeValueObject.getAttribute() ); + if ( attribute != null ) + { + attribute.add( newAttributeValueObject.getValue() ); + } + else + { + contextEntry.put( new BasicAttribute( newAttributeValueObject.getAttribute(), + newAttributeValueObject.getValue() ) ); + } + + contextEntryTableViewer.refresh(); + resizeContextEntryTableColumnsToFit(); + masterDetailsBlock.setEditorDirty(); + } } }; @@ -138,7 +183,7 @@ { public void widgetSelected( SelectionEvent e ) { - // masterDetailsBlock.setEditorDirty(); + editSelectedContextEntry(); } }; @@ -147,7 +192,20 @@ { public void widgetSelected( SelectionEvent e ) { - masterDetailsBlock.setEditorDirty(); + StructuredSelection selection = ( StructuredSelection ) contextEntryTableViewer.getSelection(); + if ( !selection.isEmpty() ) + { + AttributeValueObject attributeValueObject = ( AttributeValueObject ) selection.getFirstElement(); + + Attribute attribute = contextEntry.get( attributeValueObject.getAttribute() ); + if ( attribute != null ) + { + attribute.remove( attributeValueObject.getValue() ); + contextEntryTableViewer.refresh(); + resizeContextEntryTableColumnsToFit(); + masterDetailsBlock.setEditorDirty(); + } + } } }; @@ -176,7 +234,6 @@ public void widgetSelected( SelectionEvent e ) { IndexedAttributeDialog dialog = new IndexedAttributeDialog( new IndexedAttribute( "", 0 ) ); - if ( Dialog.OK == dialog.open() ) { indexedAttributes.add( dialog.getIndexedAttribute() ); @@ -207,7 +264,6 @@ indexedAttributes.remove( indexedAttribute ); indexedAttributesTableViewer.refresh(); - masterDetailsBlock.setEditorDirty(); } } @@ -323,13 +379,103 @@ client.setLayout( new GridLayout( 2, false ) ); section.setClient( client ); - Table contextEntryTable = toolkit.createTable( client, SWT.NONE ); + contextEntryTable = toolkit.createTable( client, SWT.NONE ); GridData gd = new GridData( SWT.FILL, SWT.NONE, true, false, 1, 3 ); - gd.heightHint = 80; + gd.heightHint = 103; contextEntryTable.setLayoutData( gd ); + TableColumn idColumn = new TableColumn( contextEntryTable, SWT.LEFT, 0 ); + idColumn.setText( "Attribute" ); + idColumn.setWidth( 100 ); + TableColumn valueColumn = new TableColumn( contextEntryTable, SWT.LEFT, 1 ); + valueColumn.setText( "Value" ); + valueColumn.setWidth( 100 ); + contextEntryTable.setHeaderVisible( true ); contextEntryTableViewer = new TableViewer( contextEntryTable ); - contextEntryTableViewer.setContentProvider( new ArrayContentProvider() ); - contextEntryTableViewer.setLabelProvider( new LabelProvider() ); + contextEntryTableViewer.setContentProvider( new IStructuredContentProvider() + { + public Object[] getElements( Object inputElement ) + { + List elements = new ArrayList(); + + Attributes attributes = ( Attributes ) inputElement; + + NamingEnumeration ne = attributes.getAll(); + while ( ne.hasMoreElements() ) + { + Attribute attribute = ( Attribute ) ne.nextElement(); + try + { + NamingEnumeration values = attribute.getAll(); + while ( values.hasMoreElements() ) + { + elements.add( new AttributeValueObject( attribute.getID(), values.nextElement() ) ); + } + } + catch ( NamingException e ) + { + } + } + + return elements.toArray(); + } + + + public void dispose() + { + } + + + public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) + { + } + } ); + contextEntryTableViewer.setLabelProvider( new ITableLabelProvider() + { + public String getColumnText( Object element, int columnIndex ) + { + if ( element != null ) + { + switch ( columnIndex ) + { + case 0: + return ( ( AttributeValueObject ) element ).getAttribute(); + case 1: + return ( ( AttributeValueObject ) element ).getValue().toString(); + default: + break; + } + } + + return null; + } + + + public Image getColumnImage( Object element, int columnIndex ) + { + return null; + } + + + public void addListener( ILabelProviderListener listener ) + { + } + + + public void dispose() + { + } + + + public boolean isLabelProperty( Object element, String property ) + { + return false; + } + + + public void removeListener( ILabelProviderListener listener ) + { + } + } ); GridData buttonsGD = new GridData( SWT.FILL, SWT.BEGINNING, false, false ); buttonsGD.widthHint = IDialogConstants.BUTTON_WIDTH; @@ -402,7 +548,7 @@ enableOptimizerCheckbox.addSelectionListener( checkboxSelectionListener ); synchOnWriteCheckbox.addSelectionListener( checkboxSelectionListener ); - // TODO Add a listener for the double-click on the contextEntryTable + contextEntryTableViewer.addDoubleClickListener( contextEntryTableViewerDoubleClickListener ); contextEntryTableViewer.addSelectionChangedListener( contextEntryTableViewerListener ); contextEntryAddButton.addSelectionListener( contextEntryAddButtonListener ); contextEntryEditButton.addSelectionListener( contextEntryEditButtonListener ); @@ -427,7 +573,7 @@ enableOptimizerCheckbox.removeSelectionListener( checkboxSelectionListener ); synchOnWriteCheckbox.removeSelectionListener( checkboxSelectionListener ); - // TODO remove the listener for the double-click on the contextEntryTable + contextEntryTableViewer.removeDoubleClickListener( contextEntryTableViewerDoubleClickListener ); contextEntryTableViewer.removeSelectionChangedListener( contextEntryTableViewerListener ); contextEntryAddButton.removeSelectionListener( contextEntryAddButtonListener ); contextEntryEditButton.removeSelectionListener( contextEntryEditButtonListener ); @@ -531,6 +677,11 @@ // Synchronization on write synchOnWriteCheckbox.setSelection( input.isSynchronizationOnWrite() ); + // Context Entry + contextEntry = input.getContextEntry(); + contextEntryTableViewer.setInput( contextEntry ); + resizeContextEntryTableColumnsToFit(); + // Indexed Attributes indexedAttributes = input.getIndexedAttributes(); indexedAttributesTableViewer.setInput( indexedAttributes ); @@ -539,6 +690,20 @@ } + /** + * Resizes the columns to fit the size of the cells. + */ + private void resizeContextEntryTableColumnsToFit() + { + // Resizing the first column + contextEntryTable.getColumn( 0 ).pack(); + // Adding a little space to the first column + contextEntryTable.getColumn( 0 ).setWidth( contextEntryTable.getColumn( 0 ).getWidth() + 5 ); + // Resizing the second column + contextEntryTable.getColumn( 1 ).pack(); + } + + /* (non-Javadoc) * @see org.eclipse.ui.forms.IFormPart#setFocus() */ @@ -572,6 +737,49 @@ if ( Dialog.OK == dialog.open() && dialog.isDirty() ) { indexedAttributesTableViewer.refresh(); + masterDetailsBlock.setEditorDirty(); + } + } + } + + + /** + * Opens a Context Entry Dialog with the selected Attribute Value Object in the + * Context Entry Table Viewer. + */ + private void editSelectedContextEntry() + { + StructuredSelection selection = ( StructuredSelection ) contextEntryTableViewer.getSelection(); + if ( !selection.isEmpty() ) + { + AttributeValueObject attributeValueObject = ( AttributeValueObject ) selection.getFirstElement(); + + String oldId = attributeValueObject.getAttribute(); + Object oldValue = attributeValueObject.getValue(); + + AttributeValueDialog dialog = new AttributeValueDialog( attributeValueObject ); + if ( Dialog.OK == dialog.open() && dialog.isDirty() ) + { + Attribute attribute = contextEntry.get( oldId ); + if ( attribute != null ) + { + attribute.remove( oldValue ); + } + + AttributeValueObject newAttributeValueObject = dialog.getAttributeValueObject(); + attribute = contextEntry.get( newAttributeValueObject.getAttribute() ); + if ( attribute != null ) + { + attribute.add( newAttributeValueObject.getValue() ); + } + else + { + contextEntry.put( new BasicAttribute( newAttributeValueObject.getAttribute(), + newAttributeValueObject.getValue() ) ); + } + + contextEntryTableViewer.refresh(); + resizeContextEntryTableColumnsToFit(); masterDetailsBlock.setEditorDirty(); } } Modified: directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java?view=diff&rev=528468&r1=528467&r2=528468 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java (original) +++ directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java Fri Apr 13 05:41:12 2007 @@ -134,12 +134,13 @@ { public Image getImage( Object element ) { - return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_PARTITION ) - .createImage(); + + return AbstractUIPlugin.imageDescriptorFromPlugin( + Activator.PLUGIN_ID, + ( ( Partition ) element ).isSystemPartition() ? PluginConstants.IMG_PARTITION_SYSTEM + : PluginConstants.IMG_PARTITION ).createImage(); } } ); - viewer.setInput( new Object[] - { new Partition( "System Partition" ), new Partition( "Example Partition" ) } ); // Creating the button(s) addButton = toolkit.createButton( client, "Add...", SWT.PUSH ); //$NON-NLS-1$ @@ -175,6 +176,15 @@ viewer.refresh(); deleteButton.setEnabled( !event.getSelection().isEmpty() ); + StructuredSelection selection = ( StructuredSelection ) viewer.getSelection(); + if ( !selection.isEmpty() ) + { + Partition partition = ( Partition ) selection.getFirstElement(); + if ( partition.isSystemPartition() ) + { + deleteButton.setEnabled( false ); + } + } } } ); @@ -198,10 +208,12 @@ if ( !selection.isEmpty() ) { Partition partition = ( Partition ) selection.getFirstElement(); - - partitions.remove( partition ); - viewer.refresh(); - setEditorDirty(); + if ( !partition.isSystemPartition() ) + { + partitions.remove( partition ); + viewer.refresh(); + setEditorDirty(); + } } } } ); @@ -232,7 +244,6 @@ ok = false; } } - counter++; } Modified: directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/model/Partition.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/model/Partition.java?view=diff&rev=528468&r1=528467&r2=528468 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/model/Partition.java (original) +++ directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/model/Partition.java Fri Apr 13 05:41:12 2007 @@ -24,6 +24,7 @@ import java.util.List; import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttributes; /** @@ -55,6 +56,9 @@ /** The indexed attributes */ private List indexedAttributes; + /** The System Partition flag */ + private boolean systemPartition; + /** * Creates a new instance of Partition. @@ -62,6 +66,7 @@ public Partition() { indexedAttributes = new ArrayList(); + contextEntry = new BasicAttributes( true ); } @@ -71,10 +76,11 @@ * @param name * the name of the partition */ - public Partition( String name ) + public Partition( String name ) { - this.name = name; indexedAttributes = new ArrayList(); + contextEntry = new BasicAttributes( true ); + this.name = name; } @@ -271,6 +277,30 @@ public void setSynchronizationOnWrite( boolean synchronizationOnWrite ) { this.synchronizationOnWrite = synchronizationOnWrite; + } + + + /** + * Returns the System Partition flag. + * + * @return + * true if the partition is the System Partition + */ + public boolean isSystemPartition() + { + return systemPartition; + } + + + /** + * Sets the System Partition flag. + * + * @param systemPartition + * the System Partition flag + */ + public void setSystemPartition( boolean systemPartition ) + { + this.systemPartition = systemPartition; }