directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r657131 - in /directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration: editor/v152/ editor/v152/dialogs/ model/v152/
Date Fri, 16 May 2008 16:52:25 GMT
Author: pamarcelot
Date: Fri May 16 09:52:24 2008
New Revision: 657131

URL: http://svn.apache.org/viewvc?rev=657131&view=rev
Log:
o Removed old ExtendedOperation class.
o Added ExtendedOperationEnum enum which contains all extended operations.
o Adapted the UI for extended operations.
o Updated parser/writer to read/write extended operations

Added:
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/dialogs/ExtendedOperationDialog.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ExtendedOperationEnum.java
Removed:
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ExtendedOperation.java
Modified:
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/ExtendedOperationDetailsPage.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/ExtendedOperationsMasterDetailsBlock.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/InterceptorDetailsPage.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerConfigurationV152.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerXmlIOV152.java

Modified: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/ExtendedOperationDetailsPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/ExtendedOperationDetailsPage.java?rev=657131&r1=657130&r2=657131&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/ExtendedOperationDetailsPage.java
(original)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/ExtendedOperationDetailsPage.java
Fri May 16 09:52:24 2008
@@ -20,7 +20,7 @@
 package org.apache.directory.studio.apacheds.configuration.editor.v152;
 
 
-import org.apache.directory.studio.apacheds.configuration.model.v152.ExtendedOperation;
+import org.apache.directory.studio.apacheds.configuration.model.v152.ExtendedOperationEnum;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.swt.SWT;
@@ -54,13 +54,14 @@
     private IManagedForm mform;
 
     /** The input Interceptor */
-    private ExtendedOperation input;
+    private ExtendedOperationEnum input;
 
     /** The dirty flag */
     private boolean dirty = false;
 
     // UI fields
-    private Text classTypeText;
+    private Text nameText;
+    private Text descriptionText;
 
     // Listeners
     /** The Modify Listener for Text Widgets */
@@ -113,43 +114,32 @@
      */
     private void createDetailsSection( Composite parent, FormToolkit toolkit )
     {
-        Section section = toolkit.createSection( parent, Section.DESCRIPTION | Section.TITLE_BAR
);
+        Section section = toolkit.createSection( parent, Section.TITLE_BAR );
         section.marginWidth = 10;
         section.setText( "Extended Operation Details" ); //$NON-NLS-1$
-        section.setDescription( "Set the properties of the extended operation." ); //$NON-NLS-1$
         TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
         td.grabHorizontal = true;
         section.setLayoutData( td );
         Composite client = toolkit.createComposite( section );
         toolkit.paintBordersFor( client );
-        GridLayout glayout = new GridLayout( 3, false );
+        GridLayout glayout = new GridLayout( 2, false );
         client.setLayout( glayout );
         section.setClient( client );
 
-        // Class
-        toolkit.createLabel( client, "Class:" );
-        classTypeText = toolkit.createText( client, "" );
-        classTypeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1
) );
-
-        addListeners();
-    }
-
-
-    /**
-     * Adds listeners to UI fields.
-     */
-    private void addListeners()
-    {
-        classTypeText.addModifyListener( textModifyListener );
-    }
-
-
-    /**
-     * Removes listeners to UI fields.
-     */
-    private void removeListeners()
-    {
-        classTypeText.removeModifyListener( textModifyListener );
+        // Name
+        toolkit.createLabel( client, "Name:" );
+        nameText = toolkit.createText( client, "" );
+        nameText.setEditable( false );
+        nameText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Description
+        toolkit.createLabel( client, "Description:" );
+        descriptionText = toolkit.createText( client, "", SWT.MULTI | SWT.WRAP | SWT.V_SCROLL
);
+        descriptionText.setEditable( false );
+        GridData gridData = new GridData( SWT.FILL, SWT.NONE, true, false );
+        gridData.widthHint = 100;
+        gridData.heightHint = 75;
+        descriptionText.setLayoutData( gridData );
     }
 
 
@@ -161,7 +151,7 @@
         IStructuredSelection ssel = ( IStructuredSelection ) selection;
         if ( ssel.size() == 1 )
         {
-            input = ( ExtendedOperation ) ssel.getFirstElement();
+            input = ( ExtendedOperationEnum ) ssel.getFirstElement();
         }
         else
         {
@@ -176,10 +166,6 @@
      */
     public void commit( boolean onSave )
     {
-        if ( input != null )
-        {
-            input.setClassType( classTypeText.getText() );
-        }
     }
 
 
@@ -223,11 +209,13 @@
      */
     public void refresh()
     {
-        removeListeners();
-
-        classTypeText.setText( input.getClassType() );
-
-        addListeners();
+        // Name
+        String name = input.getName();
+        nameText.setText( ( name == null ) ? "" : name );
+
+        // Description
+        String description = input.getDescription();
+        descriptionText.setText( ( description == null ) ? "" : description );
     }
 
 
@@ -236,7 +224,7 @@
      */
     public void setFocus()
     {
-        classTypeText.setFocus();
+        nameText.setFocus();
     }
 
 

Modified: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/ExtendedOperationsMasterDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/ExtendedOperationsMasterDetailsBlock.java?rev=657131&r1=657130&r2=657131&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/ExtendedOperationsMasterDetailsBlock.java
(original)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/ExtendedOperationsMasterDetailsBlock.java
Fri May 16 09:52:24 2008
@@ -25,15 +25,18 @@
 import org.apache.directory.studio.apacheds.configuration.ApacheDSConfigurationPlugin;
 import org.apache.directory.studio.apacheds.configuration.ApacheDSConfigurationPluginConstants;
 import org.apache.directory.studio.apacheds.configuration.editor.ServerConfigurationEditor;
-import org.apache.directory.studio.apacheds.configuration.model.v152.ExtendedOperation;
+import org.apache.directory.studio.apacheds.configuration.editor.v152.dialogs.ExtendedOperationDialog;
+import org.apache.directory.studio.apacheds.configuration.model.v152.ExtendedOperationEnum;
 import org.apache.directory.studio.apacheds.configuration.model.v152.ServerConfigurationV152;
 import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.CheckboxTableViewer;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 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.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
@@ -68,15 +71,13 @@
     private ServerConfigurationV152 serverConfiguration;
 
     /** The Extended Operations List */
-    private List<ExtendedOperation> extendedOperations;
+    private List<ExtendedOperationEnum> extendedOperations;
 
     /** The Details Page */
     private ExtendedOperationDetailsPage detailsPage;
 
-    private static final String NEW_NAME = "newExtendedOperation";
-
     // UI Fields
-    private CheckboxTableViewer viewer;
+    private TableViewer viewer;
     private Button addButton;
     private Button deleteButton;
 
@@ -89,7 +90,8 @@
     public ExtendedOperationsMasterDetailsBlock( FormPage page )
     {
         this.page = page;
-        serverConfiguration = ( ServerConfigurationV152 ) ( ( ServerConfigurationEditor )
page.getEditor() ).getServerConfiguration();
+        serverConfiguration = ( ServerConfigurationV152 ) ( ( ServerConfigurationEditor )
page.getEditor() )
+            .getServerConfiguration();
         extendedOperations = serverConfiguration.getExtendedOperations();
     }
 
@@ -117,14 +119,14 @@
         section.setClient( client );
 
         // Creatig the Table and Table Viewer
-        Table table = toolkit.createTable( client, SWT.CHECK );
+        Table table = toolkit.createTable( client, SWT.NULL );
         GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 2 );
         gd.heightHint = 20;
         gd.widthHint = 100;
         table.setLayoutData( gd );
         final SectionPart spart = new SectionPart( section );
         managedForm.addPart( spart );
-        viewer = new CheckboxTableViewer( table );
+        viewer = new TableViewer( table );
         viewer.addSelectionChangedListener( new ISelectionChangedListener()
         {
             public void selectionChanged( SelectionChangedEvent event )
@@ -183,11 +185,15 @@
         {
             public void widgetSelected( SelectionEvent e )
             {
-                ExtendedOperation newExtendedOperation = new ExtendedOperation( getNewName()
);
-                extendedOperations.add( newExtendedOperation );
-                viewer.refresh();
-                viewer.setSelection( new StructuredSelection( newExtendedOperation ) );
-                setEditorDirty();
+                ExtendedOperationDialog dialog = new ExtendedOperationDialog( extendedOperations
);
+                if ( Dialog.OK == dialog.open() )
+                {
+                    ExtendedOperationEnum newExtendedOperation = dialog.getExtendedOperation();
+                    extendedOperations.add( newExtendedOperation );
+                    viewer.refresh();
+                    viewer.setSelection( new StructuredSelection( newExtendedOperation )
);
+                    setEditorDirty();
+                }
             }
         } );
 
@@ -198,7 +204,7 @@
                 StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
                 if ( !selection.isEmpty() )
                 {
-                    ExtendedOperation extendedOperation = ( ExtendedOperation ) selection.getFirstElement();
+                    ExtendedOperationEnum extendedOperation = ( ExtendedOperationEnum ) selection.getFirstElement();
 
                     extendedOperations.remove( extendedOperation );
                     viewer.refresh();
@@ -209,38 +215,6 @@
     }
 
 
-    /**
-     * Gets a new Name for a new Extended Operation.
-     *
-     * @return 
-     *      a new Name for a new Extended Operation
-     */
-    private String getNewName()
-    {
-        int counter = 1;
-        String name = NEW_NAME;
-        boolean ok = false;
-
-        while ( !ok )
-        {
-            ok = true;
-            name = NEW_NAME + counter;
-
-            for ( ExtendedOperation extendedOperation : extendedOperations )
-            {
-                if ( extendedOperation.getClassType().equalsIgnoreCase( name ) )
-                {
-                    ok = false;
-                }
-            }
-
-            counter++;
-        }
-
-        return name;
-    }
-
-
     /* (non-Javadoc)
      * @see org.eclipse.ui.forms.MasterDetailsBlock#createToolBarActions(org.eclipse.ui.forms.IManagedForm)
      */
@@ -285,7 +259,7 @@
     protected void registerPages( DetailsPart detailsPart )
     {
         detailsPage = new ExtendedOperationDetailsPage( this );
-        detailsPart.registerPage( ExtendedOperation.class, detailsPage );
+        detailsPart.registerPage( ExtendedOperationEnum.class, detailsPage );
     }
 
 

Modified: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/InterceptorDetailsPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/InterceptorDetailsPage.java?rev=657131&r1=657130&r2=657131&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/InterceptorDetailsPage.java
(original)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/InterceptorDetailsPage.java
Fri May 16 09:52:24 2008
@@ -24,9 +24,6 @@
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-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;
@@ -64,17 +61,6 @@
     private Text nameText;
     private Text descriptionText;
 
-    // Listeners
-    /** The Modify Listener for Text Widgets */
-    private ModifyListener textModifyListener = new ModifyListener()
-    {
-        public void modifyText( ModifyEvent e )
-        {
-            masterDetailsBlock.setEditorDirty();
-            dirty = true;
-        }
-    };
-
 
     /**
      * Creates a new instance of InterceptorDetailsPage.
@@ -115,10 +101,9 @@
      */
     private void createDetailsSection( Composite parent, FormToolkit toolkit )
     {
-        Section section = toolkit.createSection( parent, Section.DESCRIPTION | Section.TITLE_BAR
);
+        Section section = toolkit.createSection( parent, Section.TITLE_BAR );
         section.marginWidth = 10;
         section.setText( "Interceptor Details" ); //$NON-NLS-1$
-        section.setDescription( "Set the properties of the interceptor." ); //$NON-NLS-1$
         TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
         td.grabHorizontal = true;
         section.setLayoutData( td );
@@ -145,22 +130,6 @@
     }
 
 
-    /**
-     * Adds listeners to UI fields.
-     */
-    private void addListeners()
-    {
-    }
-
-
-    /**
-     * Removes listeners to UI fields.
-     */
-    private void removeListeners()
-    {
-    }
-
-
     /* (non-Javadoc)
      * @see org.eclipse.ui.forms.IPartSelectionListener#selectionChanged(org.eclipse.ui.forms.IFormPart,
org.eclipse.jface.viewers.ISelection)
      */
@@ -184,10 +153,6 @@
      */
     public void commit( boolean onSave )
     {
-        if ( input != null )
-        {
-            //TODO
-        }
     }
 
 
@@ -231,8 +196,6 @@
      */
     public void refresh()
     {
-        removeListeners();
-
         // Name
         String name = input.getName();
         nameText.setText( ( name == null ) ? "" : name );
@@ -240,8 +203,6 @@
         // Description
         String description = input.getDescription();
         descriptionText.setText( ( description == null ) ? "" : description );
-
-        addListeners();
     }
 
 

Added: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/dialogs/ExtendedOperationDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/dialogs/ExtendedOperationDialog.java?rev=657131&view=auto
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/dialogs/ExtendedOperationDialog.java
(added)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v152/dialogs/ExtendedOperationDialog.java
Fri May 16 09:52:24 2008
@@ -0,0 +1,241 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.configuration.editor.v152.dialogs;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.apacheds.configuration.ApacheDSConfigurationPlugin;
+import org.apache.directory.studio.apacheds.configuration.ApacheDSConfigurationPluginConstants;
+import org.apache.directory.studio.apacheds.configuration.model.v152.ExtendedOperationEnum;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+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.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+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.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * This class implements the Dialog for Extended Operation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExtendedOperationDialog extends Dialog
+{
+    /** The initial extended operations list */
+    private List<ExtendedOperationEnum> initialExtendedOperations;
+
+    /** The available extended operations list */
+    private List<ExtendedOperationEnum> availableExtendedOperations;
+
+    /** The selected extended operation */
+    private ExtendedOperationEnum selectedExtendedOperation;
+
+    // UI Fields
+    private Table extendedOperationsTable;
+    private TableViewer extendedOperationsTableViewer;
+    private Button addButton;
+
+
+    /**
+     * Creates a new instance of ExtendedOperationDialog.
+     */
+    public ExtendedOperationDialog( List<ExtendedOperationEnum> extendedOperations
)
+    {
+        super( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
+        this.initialExtendedOperations = extendedOperations;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
+    protected void configureShell( Shell newShell )
+    {
+        super.configureShell( newShell );
+        newShell.setText( "Add An Extended Operation" );
+    }
+
+
+    /* (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 );
+        composite.setLayout( new GridLayout() );
+        composite.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true )
);
+
+        // Choose Label
+        Label chooseLabel = new Label( composite, SWT.NONE );
+        chooseLabel.setText( "Choose an extended operation:" );
+        chooseLabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Interceptors Table Viewer
+        extendedOperationsTable = new Table( composite, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL
| SWT.V_SCROLL
+            | SWT.FULL_SELECTION | SWT.HIDE_SELECTION );
+        GridData gridData = new GridData( SWT.FILL, SWT.FILL, true, true );
+        gridData.heightHint = 148;
+        gridData.minimumHeight = 148;
+        gridData.widthHint = 350;
+        gridData.minimumWidth = 350;
+        extendedOperationsTable.setLayoutData( gridData );
+        extendedOperationsTable.addMouseListener( new MouseAdapter()
+        {
+            public void mouseDoubleClick( MouseEvent e )
+            {
+                if ( extendedOperationsTable.getSelectionIndex() != -1 )
+                {
+                    okPressed();
+                }
+            }
+        } );
+
+        extendedOperationsTableViewer = new TableViewer( extendedOperationsTable );
+        extendedOperationsTableViewer.setContentProvider( new ArrayContentProvider() );
+        extendedOperationsTableViewer.setLabelProvider( new LabelProvider()
+        {
+            public Image getImage( Object element )
+            {
+                return ApacheDSConfigurationPlugin.getDefault().getImage(
+                    ApacheDSConfigurationPluginConstants.IMG_EXTENDED_OPERATION );
+            }
+
+
+            public String getText( Object element )
+            {
+                if ( element instanceof ExtendedOperationEnum )
+                {
+                    return ( ( ExtendedOperationEnum ) element ).getName();
+
+                }
+
+                return super.getText( element );
+            }
+        } );
+        extendedOperationsTableViewer.addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                StructuredSelection selection = ( StructuredSelection ) extendedOperationsTableViewer.getSelection();
+                if ( selection.isEmpty() )
+                {
+                    if ( ( addButton != null ) && ( !addButton.isDisposed() ) )
+                    {
+                        addButton.setEnabled( false );
+                    }
+                }
+                else
+                {
+                    if ( ( addButton != null ) && ( !addButton.isDisposed() ) )
+                    {
+                        addButton.setEnabled( true );
+                    }
+                }
+            }
+        } );
+
+        initFromInput();
+
+        return composite;
+    }
+
+
+    /**
+     * Initializes the UI from the input.
+     */
+    private void initFromInput()
+    {
+        // Creating the available extended operations list
+        availableExtendedOperations = new ArrayList<ExtendedOperationEnum>();
+        if ( !initialExtendedOperations.contains( ExtendedOperationEnum.START_TLS ) )
+        {
+            availableExtendedOperations.add( ExtendedOperationEnum.START_TLS );
+        }
+        if ( !initialExtendedOperations.contains( ExtendedOperationEnum.GRACEFUL_SHUTDOWN
) )
+        {
+            availableExtendedOperations.add( ExtendedOperationEnum.GRACEFUL_SHUTDOWN );
+        }
+        if ( !initialExtendedOperations.contains( ExtendedOperationEnum.LAUNCH_DIAGNOSTIC_UI
) )
+        {
+            availableExtendedOperations.add( ExtendedOperationEnum.LAUNCH_DIAGNOSTIC_UI );
+        }
+
+        // Setting the input
+        extendedOperationsTableViewer.setInput( availableExtendedOperations );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+     */
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        addButton = createButton( parent, IDialogConstants.OK_ID, "Add", true ); //$NON-NLS-1$
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL,
false );
+
+        addButton.setEnabled( false );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+     */
+    protected void okPressed()
+    {
+        StructuredSelection selection = ( StructuredSelection ) extendedOperationsTableViewer.getSelection();
+        if ( !selection.isEmpty() )
+        {
+            selectedExtendedOperation = ( ExtendedOperationEnum ) selection.getFirstElement();
+        }
+
+        super.okPressed();
+    }
+
+
+    /**
+     * Gets the extended operation.
+     *
+     * @return
+     *      the extended operation
+     */
+    public ExtendedOperationEnum getExtendedOperation()
+    {
+        return selectedExtendedOperation;
+    }
+}

Added: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ExtendedOperationEnum.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ExtendedOperationEnum.java?rev=657131&view=auto
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ExtendedOperationEnum.java
(added)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ExtendedOperationEnum.java
Fri May 16 09:52:24 2008
@@ -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.studio.apacheds.configuration.model.v152;
+
+
+/**
+ * This enum contains all the extended operations.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public enum ExtendedOperationEnum
+{
+    /** The Start TLS Extended Operation */
+    START_TLS("Start TLS", "Description"),
+
+    /** The Graceful Shutdown Extended Operation */
+    GRACEFUL_SHUTDOWN("Graceful Shutdown", "Description"),
+
+    /** The Launch Diagnostic UI Extended Operation */
+    LAUNCH_DIAGNOSTIC_UI("Launch Diagnostic UI", "Description");
+
+    /** The name */
+    private String name;
+
+    /** The description */
+    private String description;
+
+
+    /**
+     * Creates a new instance of InterceptorEnum.
+     *
+     * @param name
+     *      the name
+     * @param description
+     *      the description
+     */
+    private ExtendedOperationEnum( String name, String description )
+    {
+        this.name = name;
+        this.description = description;
+    }
+
+
+    /**
+     * Gets the name.
+     *
+     * @return
+     *      the name
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+
+    /**
+     * Sets the name.
+     *
+     * @param name
+     *      the name
+     */
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+
+    /**
+     * Gets the description.
+     *
+     * @return
+     *      the description
+     */
+    public String getDescription()
+    {
+        return description;
+    }
+
+
+    /**
+     * Sets the description.
+     *
+     * @param description
+     *      the description
+     */
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+}

Modified: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerConfigurationV152.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerConfigurationV152.java?rev=657131&r1=657130&r2=657131&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerConfigurationV152.java
(original)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerConfigurationV152.java
Fri May 16 09:52:24 2008
@@ -136,7 +136,7 @@
     private List<InterceptorEnum> interceptors;
 
     /** The Extended Operations */
-    private List<ExtendedOperation> extendedOperations;
+    private List<ExtendedOperationEnum> extendedOperations;
 
 
     /**
@@ -151,7 +151,7 @@
         saslRealms = new ArrayList<String>();
         partitions = new ArrayList<Partition>();
         interceptors = new ArrayList<InterceptorEnum>();
-        extendedOperations = new ArrayList<ExtendedOperation>();
+        extendedOperations = new ArrayList<ExtendedOperationEnum>();
         binaryAttributes = new ArrayList<String>();
     }
 
@@ -178,7 +178,7 @@
      * @return
      *      true (as per the general contract of the Collection.add method).
      */
-    public boolean addExtendedOperation( ExtendedOperation extendedOperation )
+    public boolean addExtendedOperation( ExtendedOperationEnum extendedOperation )
     {
         return extendedOperations.add( extendedOperation );
     }
@@ -332,7 +332,7 @@
      * @return
      *      the Extended Operations List
      */
-    public List<ExtendedOperation> getExtendedOperations()
+    public List<ExtendedOperationEnum> getExtendedOperations()
     {
         return extendedOperations;
     }
@@ -672,7 +672,7 @@
      * @return
      *      true if this list contained the specified element.
      */
-    public boolean removeExtendedOperation( ExtendedOperation extendedOperation )
+    public boolean removeExtendedOperation( ExtendedOperationEnum extendedOperation )
     {
         return extendedOperations.remove( extendedOperation );
     }
@@ -886,7 +886,7 @@
      * @param extendedOperations
      *      the new value
      */
-    public void setExtendedOperations( List<ExtendedOperation> extendedOperations )
+    public void setExtendedOperations( List<ExtendedOperationEnum> extendedOperations
)
     {
         this.extendedOperations = extendedOperations;
     }

Modified: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerXmlIOV152.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerXmlIOV152.java?rev=657131&r1=657130&r2=657131&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerXmlIOV152.java
(original)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerXmlIOV152.java
Fri May 16 09:52:24 2008
@@ -597,7 +597,7 @@
             // Looping on all interceptor elements
             for ( Iterator<?> i = interceptorsElement.elementIterator(); i.hasNext();
)
             {
-                // Getting the 'jbdmPartition' element
+                // Getting the element
                 Element interceptorElement = ( Element ) i.next();
 
                 // Checking which interceptor it is
@@ -910,7 +910,7 @@
                         // If the 'ipPort' attribute does not exists,
                         // we throw an exception
                         throw new ServerXmlIOException(
-                            "Unable to find the 'ipPort' attribute for the 'ldapsServer'
bean." );
+                            "Unable to find the 'ipPort' attribute for the 'ldapServer' bean."
);
                     }
                     else
                     {
@@ -924,13 +924,16 @@
                         // If the 'allowAnonymousAccess' attribute does not exists,
                         // we throw an exception
                         throw new ServerXmlIOException(
-                            "Unable to find the 'allowAnonymousAccess' attribute for the
'ldapsServer' bean." );
+                            "Unable to find the 'allowAnonymousAccess' attribute for the
'ldapServer' bean." );
                     }
                     else
                     {
                         serverConfiguration.setAllowAnonymousAccess( parseBoolean( allowAnonymousAccess.getValue()
) );
                     }
 
+                    // Extended operations
+                    readExtendedOperations( ldapServerElement, serverConfiguration );
+
                     return;
                 }
             }
@@ -939,6 +942,46 @@
 
 
     /**
+     * Reads the extended operations.
+     *
+     * @param element
+     *      the element
+     * @param serverConfiguration
+     *      the server configuration
+     */
+    private void readExtendedOperations( Element element, ServerConfigurationV152 serverConfiguration
)
+    {
+        // Getting the 'interceptors
+        Element interceptorsElement = element.element( "extendedOperationHandlers" );
+        if ( interceptorsElement != null )
+        {
+            // Looping on all interceptor elements
+            for ( Iterator<?> i = interceptorsElement.elementIterator(); i.hasNext();
)
+            {
+                // Getting the element
+                Element extendedOperationElement = ( Element ) i.next();
+
+                // Checking which extended operation it is
+                String extendedOperationElementName = extendedOperationElement.getName();
+                if ( "startTlsHandler".equalsIgnoreCase( extendedOperationElementName ) )
+                {
+                    serverConfiguration.addExtendedOperation( ExtendedOperationEnum.START_TLS
);
+                }
+                if ( "gracefulShutdownHandler".equalsIgnoreCase( extendedOperationElementName
) )
+                {
+                    serverConfiguration.addExtendedOperation( ExtendedOperationEnum.GRACEFUL_SHUTDOWN
);
+                }
+                if ( "launchDiagnosticUiHandler".equalsIgnoreCase( extendedOperationElementName
) )
+                {
+                    serverConfiguration.addExtendedOperation( ExtendedOperationEnum.LAUNCH_DIAGNOSTIC_UI
);
+                }
+            }
+
+        }
+    }
+
+
+    /**
      * Reads the ApacheDS Bean.
      *
      * @param element
@@ -1580,7 +1623,23 @@
             saslRealmsElement.addElement( new QName( "value", NAMESPACE_SPRINGFRAMEWORK )
).setText( saslRealm );
         }
 
-        // TODO Add Extended Operations
+        // Adding 'ExtendedOperations' element
+        Element extendedOperationsElement = ldapServerElement.addElement( "extendedOperations"
);
+
+        // Adding each extended operation item
+        List<ExtendedOperationEnum> extendedOperations = serverConfiguration.getExtendedOperations();
+        if ( extendedOperations.contains( ExtendedOperationEnum.START_TLS ) )
+        {
+            extendedOperationsElement.addElement( "startTlsHandler" );
+        }
+        if ( extendedOperations.contains( ExtendedOperationEnum.GRACEFUL_SHUTDOWN ) )
+        {
+            extendedOperationsElement.addElement( "gracefulShutDownHandler" );
+        }
+        if ( extendedOperations.contains( ExtendedOperationEnum.LAUNCH_DIAGNOSTIC_UI ) )
+        {
+            extendedOperationsElement.addElement( "launchDiagnosticUiHandler" );
+        }
     }
 
 
@@ -1600,8 +1659,8 @@
         // Id
         apacheDSElement.addAttribute( "id", "apacheDS" );
 
-        // SyncPeriodMillis
-        apacheDSElement.addAttribute( "syncPeriodMillis", "" + serverConfiguration.getSynchronizationPeriod()
);
+        // SynchPeriodMillis
+        apacheDSElement.addAttribute( "synchPeriodMillis", "" + serverConfiguration.getSynchronizationPeriod()
);
 
         // AllowAnonymousAccess
         apacheDSElement.addAttribute( "allowAnonymousAccess", "" + serverConfiguration.isAllowAnonymousAccess()
);



Mime
View raw message