You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2008/05/14 19:21:48 UTC
svn commit: r656336 [4/11] - in
/directory/studio/trunk/apacheds-configuration: ./ resources/icons/
src/main/java/
src/main/java/org/apache/directory/studio/apacheds/configuration/
src/main/java/org/apache/directory/studio/apacheds/configuration/dialog...
Added: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/InterceptorsMasterDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/InterceptorsMasterDetailsBlock.java?rev=656336&view=auto
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/InterceptorsMasterDetailsBlock.java (added)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/InterceptorsMasterDetailsBlock.java Wed May 14 10:21:46 2008
@@ -0,0 +1,394 @@
+/*
+ * 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.v151;
+
+
+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.editor.ServerConfigurationEditor;
+import org.apache.directory.studio.apacheds.configuration.model.v151.Interceptor;
+import org.apache.directory.studio.apacheds.configuration.model.v151.ServerConfigurationV151;
+import org.eclipse.jface.action.Action;
+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.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.ui.forms.DetailsPart;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.MasterDetailsBlock;
+import org.eclipse.ui.forms.SectionPart;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+
+
+/**
+ * This class represents the Interceptors Master/Details Block used in the Interceptors Page.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class InterceptorsMasterDetailsBlock extends MasterDetailsBlock
+{
+ /** The associated page */
+ private FormPage page;
+
+ /** The input Server Configuration */
+ private ServerConfigurationV151 serverConfiguration;
+
+ /** The Interceptors List */
+ private List<Interceptor> interceptors;
+
+ /** The Details Page */
+ private InterceptorDetailsPage detailsPage;
+
+ private static final String NEW_NAME = "New Interceptor ";
+
+ // UI Fields
+ private CheckboxTableViewer viewer;
+ private Button addButton;
+ private Button deleteButton;
+ private Button upButton;
+ private Button downButton;
+
+
+ /**
+ * Creates a new instance of InterceptorsMasterDetailsBlock.
+ *
+ * @param page
+ */
+ public InterceptorsMasterDetailsBlock( FormPage page )
+ {
+ this.page = page;
+ serverConfiguration = ( ServerConfigurationV151 ) ( ( ServerConfigurationEditor ) page.getEditor() ).getServerConfiguration();
+ interceptors = serverConfiguration.getInterceptors();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.MasterDetailsBlock#createMasterPart(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite)
+ */
+ protected void createMasterPart( final IManagedForm managedForm, Composite parent )
+ {
+ FormToolkit toolkit = managedForm.getToolkit();
+
+ // Creating the Section
+ Section section = toolkit.createSection( parent, Section.TITLE_BAR | Section.DESCRIPTION );
+ section.setText( "All Interceptors" );
+ section
+ .setDescription( " Set the Interceptors used in the server. Use the \"Up\" and \"Down\" buttons to change the order." );
+ section.marginWidth = 10;
+ section.marginHeight = 5;
+ Composite client = toolkit.createComposite( section, SWT.WRAP );
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.makeColumnsEqualWidth = false;
+ layout.marginWidth = 2;
+ layout.marginHeight = 2;
+ client.setLayout( layout );
+ toolkit.paintBordersFor( client );
+ section.setClient( client );
+
+ // Creatig the Table and Table Viewer
+ Table table = toolkit.createTable( client, SWT.CHECK );
+ GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 4 );
+ gd.heightHint = 20;
+ gd.widthHint = 100;
+ table.setLayoutData( gd );
+ final SectionPart spart = new SectionPart( section );
+ managedForm.addPart( spart );
+ viewer = new CheckboxTableViewer( table );
+ viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ managedForm.fireSelectionChanged( spart, event.getSelection() );
+ }
+ } );
+ viewer.setContentProvider( new ArrayContentProvider() );
+ viewer.setLabelProvider( new LabelProvider()
+ {
+ public Image getImage( Object element )
+ {
+ return ApacheDSConfigurationPlugin.getDefault().getImage( ApacheDSConfigurationPluginConstants.IMG_INTERCEPTOR );
+ }
+ } );
+
+ // Creating the button(s)
+ addButton = toolkit.createButton( client, "Add...", SWT.PUSH ); //$NON-NLS-1$
+ addButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+ deleteButton = toolkit.createButton( client, "Delete", SWT.PUSH );
+ deleteButton.setEnabled( false );
+ deleteButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+ upButton = toolkit.createButton( client, "Up", SWT.PUSH );
+ upButton.setEnabled( false );
+ upButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+ downButton = toolkit.createButton( client, "Down", SWT.PUSH );
+ downButton.setEnabled( false );
+ downButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+ initFromInput();
+ addListeners();
+ }
+
+
+ /**
+ * Initializes the page with the Editor input.
+ */
+ private void initFromInput()
+ {
+ viewer.setInput( interceptors );
+ }
+
+
+ /**
+ * Add listeners to UI fields.
+ */
+ private void addListeners()
+ {
+ viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ viewer.refresh();
+
+ deleteButton.setEnabled( !event.getSelection().isEmpty() );
+
+ enableDisableUpDownButtons();
+ }
+ } );
+
+ addButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ Interceptor newInterceptor = new Interceptor( getNewName() );
+ interceptors.add( newInterceptor );
+ viewer.refresh();
+ viewer.setSelection( new StructuredSelection( newInterceptor ) );
+ setEditorDirty();
+ }
+ } );
+
+ deleteButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+ if ( !selection.isEmpty() )
+ {
+ Interceptor interceptor = ( Interceptor ) selection.getFirstElement();
+
+ interceptors.remove( interceptor );
+ viewer.refresh();
+ setEditorDirty();
+ }
+ }
+ } );
+
+ upButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+ if ( !selection.isEmpty() )
+ {
+ Interceptor interceptor = ( Interceptor ) selection.getFirstElement();
+
+ int index = interceptors.indexOf( interceptor );
+ if ( index > 0 )
+ {
+ Interceptor interceptorBefore = interceptors.get( index - 1 );
+ if ( interceptorBefore != null )
+ {
+ interceptors.set( index - 1, interceptor );
+ interceptors.set( index, interceptorBefore );
+
+ viewer.refresh();
+ setEditorDirty();
+ enableDisableUpDownButtons();
+ }
+ }
+ }
+ }
+ } );
+
+ downButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+ if ( !selection.isEmpty() )
+ {
+ Interceptor interceptor = ( Interceptor ) selection.getFirstElement();
+
+ int index = interceptors.indexOf( interceptor );
+ if ( index < ( interceptors.size() - 1 ) )
+ {
+ Interceptor interceptorAfter = interceptors.get( index + 1 );
+ if ( interceptorAfter != null )
+ {
+ interceptors.set( index + 1, interceptor );
+ interceptors.set( index, interceptorAfter );
+
+ viewer.refresh();
+ setEditorDirty();
+ enableDisableUpDownButtons();
+ }
+ }
+ }
+ }
+ } );
+ }
+
+
+ /**
+ * 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 ( Interceptor interceptor : interceptors )
+ {
+ if ( interceptor.getName().equalsIgnoreCase( name ) )
+ {
+ ok = false;
+ }
+ }
+
+ counter++;
+ }
+
+ return name;
+ }
+
+
+ /**
+ * Enables or Disables the Up and Down Buttons.
+ */
+ private void enableDisableUpDownButtons()
+ {
+ StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+
+ upButton.setEnabled( !selection.isEmpty() );
+ downButton.setEnabled( !selection.isEmpty() );
+ if ( !selection.isEmpty() )
+ {
+ Interceptor interceptor = ( Interceptor ) selection.getFirstElement();
+ upButton.setEnabled( interceptors.indexOf( interceptor ) != 0 );
+ downButton.setEnabled( interceptors.indexOf( interceptor ) != ( interceptors.size() - 1 ) );
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.MasterDetailsBlock#createToolBarActions(org.eclipse.ui.forms.IManagedForm)
+ */
+ protected void createToolBarActions( IManagedForm managedForm )
+ {
+ final ScrolledForm form = managedForm.getForm();
+
+ // Horizontal layout Action
+ Action horizontalAction = new Action( "Horizontal layout", Action.AS_RADIO_BUTTON ) { //$NON-NLS-1$
+ public void run()
+ {
+ sashForm.setOrientation( SWT.HORIZONTAL );
+ form.reflow( true );
+ }
+ };
+ horizontalAction.setChecked( true );
+ horizontalAction.setToolTipText( "Horizontal Orientation" ); //$NON-NLS-1$
+ horizontalAction.setImageDescriptor( ApacheDSConfigurationPlugin.getDefault().getImageDescriptor(
+ ApacheDSConfigurationPluginConstants.IMG_HORIZONTAL_ORIENTATION ) );
+
+ // Vertical layout Action
+ Action verticalAction = new Action( "Vertical Orientation", Action.AS_RADIO_BUTTON ) { //$NON-NLS-1$
+ public void run()
+ {
+ sashForm.setOrientation( SWT.VERTICAL );
+ form.reflow( true );
+ }
+ };
+ verticalAction.setChecked( false );
+ verticalAction.setToolTipText( "Vertical Orientation" ); //$NON-NLS-1$
+ verticalAction.setImageDescriptor( ApacheDSConfigurationPlugin.getDefault().getImageDescriptor(
+ ApacheDSConfigurationPluginConstants.IMG_VERTICAL_ORIENTATION ) );
+
+ form.getToolBarManager().add( horizontalAction );
+ form.getToolBarManager().add( verticalAction );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.MasterDetailsBlock#registerPages(org.eclipse.ui.forms.DetailsPart)
+ */
+ protected void registerPages( DetailsPart detailsPart )
+ {
+ detailsPage = new InterceptorDetailsPage( this );
+ detailsPart.registerPage( Interceptor.class, detailsPage );
+ }
+
+
+ /**
+ * Sets the Editor as dirty.
+ */
+ public void setEditorDirty()
+ {
+ ( ( ServerConfigurationEditor ) page.getEditor() ).setDirty( true );
+ }
+
+
+ /**
+ * Saves the necessary elements to the input model.
+ */
+ public void save()
+ {
+ detailsPage.commit( true );
+ viewer.setInput( interceptors );
+ }
+}
Added: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/InterceptorsPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/InterceptorsPage.java?rev=656336&view=auto
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/InterceptorsPage.java (added)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/InterceptorsPage.java Wed May 14 10:21:46 2008
@@ -0,0 +1,83 @@
+/*
+ * 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.v151;
+
+
+import org.apache.directory.studio.apacheds.configuration.editor.SavableFormPage;
+import org.apache.directory.studio.apacheds.configuration.editor.ServerConfigurationEditor;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+
+/**
+ * This class represents the Interceptors Page of the Server Configuration Editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class InterceptorsPage extends FormPage implements SavableFormPage
+{
+ /** The Page ID*/
+ public static final String ID = ServerConfigurationEditor.ID + ".V151.InterceptorsPage";
+
+ /** The Page Title */
+ private static final String TITLE = "Interceptors";
+
+ /** The Master/Details Block */
+ private InterceptorsMasterDetailsBlock masterDetailsBlock;
+
+
+ /**
+ * Creates a new instance of InterceptorsPage.
+ *
+ * @param editor
+ * the associated editor
+ */
+ public InterceptorsPage( FormEditor editor )
+ {
+ super( editor, ID, TITLE );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
+ */
+ protected void createFormContent( IManagedForm managedForm )
+ {
+ final ScrolledForm form = managedForm.getForm();
+ form.setText( "Interceptors" );
+ masterDetailsBlock = new InterceptorsMasterDetailsBlock( this );
+ masterDetailsBlock.createContent( managedForm );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.configuration.editor.SavableWizardPage#save()
+ */
+ public void save()
+ {
+ if ( masterDetailsBlock != null )
+ {
+ masterDetailsBlock.save();
+ }
+ }
+}
Added: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/PartitionDetailsPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/PartitionDetailsPage.java?rev=656336&view=auto
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/PartitionDetailsPage.java (added)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/PartitionDetailsPage.java Wed May 14 10:21:46 2008
@@ -0,0 +1,802 @@
+/*
+ * 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.v151;
+
+
+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.studio.apacheds.configuration.editor.v151.dialogs.AttributeValueDialog;
+import org.apache.directory.studio.apacheds.configuration.editor.v151.dialogs.AttributeValueObject;
+import org.apache.directory.studio.apacheds.configuration.editor.v151.dialogs.IndexedAttributeDialog;
+import org.apache.directory.studio.apacheds.configuration.model.v151.IndexedAttribute;
+import org.apache.directory.studio.apacheds.configuration.model.v151.Partition;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.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;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+
+/**
+ * This class represents the Details Page of the Server Configuration Editor for the Partition type
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PartitionDetailsPage implements IDetailsPage
+{
+ /** The associated Master Details Block */
+ private PartitionsMasterDetailsBlock masterDetailsBlock;
+
+ /** The Managed Form */
+ private IManagedForm mform;
+
+ /** The input Partition */
+ private Partition input;
+
+ /** The Context Entry */
+ private Attributes contextEntry;
+
+ /** The Indexed Attributes List */
+ private List<IndexedAttribute> indexedAttributes;
+
+ /** The dirty flag */
+ private boolean dirty = false;
+
+ // UI fields
+ private Text idText;
+ private Text cacheSizeText;
+ private Text suffixText;
+ private Button enableOptimizerCheckbox;
+ private Button synchOnWriteCheckbox;
+ private Table contextEntryTable;
+ private TableViewer contextEntryTableViewer;
+ private Button contextEntryAddButton;
+ private Button contextEntryEditButton;
+ private Button contextEntryDeleteButton;
+ private TableViewer indexedAttributesTableViewer;
+ private Button indexedAttributeAddButton;
+ private Button indexedAttributeEditButton;
+ private Button indexedAttributeDeleteButton;
+
+ // Listeners
+ /** The Text Modify Listener */
+ private ModifyListener textModifyListener = new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ masterDetailsBlock.setEditorDirty();
+ dirty = true;
+ }
+ };
+
+ /** The Checkbox Selection Listener */
+ private SelectionListener checkboxSelectionListener = new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ masterDetailsBlock.setEditorDirty();
+ dirty = true;
+ }
+ };
+
+ /** The Selection Changed Listener for the Context Entry Table Viewer */
+ private ISelectionChangedListener contextEntryTableViewerListener = new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ contextEntryEditButton.setEnabled( !event.getSelection().isEmpty() );
+ contextEntryDeleteButton.setEnabled( !event.getSelection().isEmpty() );
+ }
+ };
+
+ /** 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 )
+ {
+ 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();
+ dirty = true;
+ }
+ }
+ };
+
+ /** The Listener for the Edit button of the Context Entry Section */
+ private SelectionListener contextEntryEditButtonListener = new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ editSelectedContextEntry();
+ }
+ };
+
+ /** The Listener for the Delete button of the Context Entry Section */
+ private SelectionListener contextEntryDeleteButtonListener = new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ 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();
+ dirty = true;
+ }
+ }
+ }
+ };
+
+ /** The Selection Changed Listener for the Indexed Attributes Table Viewer */
+ private ISelectionChangedListener indexedAttributesTableViewerListener = new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ indexedAttributeEditButton.setEnabled( !event.getSelection().isEmpty() );
+ indexedAttributeDeleteButton.setEnabled( !event.getSelection().isEmpty() );
+ }
+ };
+
+ /** The Double Click Listener for the Indexed Attributes Table Viewer */
+ private IDoubleClickListener indexedAttributesTableViewerDoubleClickListener = new IDoubleClickListener()
+ {
+ public void doubleClick( DoubleClickEvent event )
+ {
+ editSelectedIndexedAttribute();
+ }
+ };
+
+ /** The Listener for the Add button of the Indexed Attributes Section */
+ private SelectionListener indexedAttributeAddButtonListener = new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ IndexedAttributeDialog dialog = new IndexedAttributeDialog( new IndexedAttribute( "", 0 ) );
+ if ( Dialog.OK == dialog.open() )
+ {
+ indexedAttributes.add( dialog.getIndexedAttribute() );
+ indexedAttributesTableViewer.refresh();
+ masterDetailsBlock.setEditorDirty();
+ dirty = true;
+ }
+ }
+ };
+
+ /** The Listener for the Edit button of the Indexed Attributes Section */
+ private SelectionListener indexedAttributeEditButtonListener = new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ editSelectedIndexedAttribute();
+ }
+ };
+
+ /** The Listener for the Delete button of the Indexed Attributes Section */
+ private SelectionListener indexedAttributeDeleteButtonListener = new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ StructuredSelection selection = ( StructuredSelection ) indexedAttributesTableViewer.getSelection();
+ if ( !selection.isEmpty() )
+ {
+ IndexedAttribute indexedAttribute = ( IndexedAttribute ) selection.getFirstElement();
+
+ indexedAttributes.remove( indexedAttribute );
+ indexedAttributesTableViewer.refresh();
+ masterDetailsBlock.setEditorDirty();
+ dirty = true;
+ }
+ }
+ };
+
+
+ /**
+ * Creates a new instance of PartitionDetailsPage.
+ *
+ * @param pmdb
+ * the associated Master Details Block
+ */
+ public PartitionDetailsPage( PartitionsMasterDetailsBlock pmdb )
+ {
+ masterDetailsBlock = pmdb;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ public void createContents( Composite parent )
+ {
+ FormToolkit toolkit = mform.getToolkit();
+ TableWrapLayout layout = new TableWrapLayout();
+ layout.topMargin = 5;
+ layout.leftMargin = 5;
+ layout.rightMargin = 2;
+ layout.bottomMargin = 2;
+ parent.setLayout( layout );
+
+ createDetailsSection( parent, toolkit );
+ createContextEntrySection( parent, toolkit );
+ createIndexedAttributesSection( parent, toolkit );
+ }
+
+
+ /**
+ * Creates the Details Section
+ *
+ * @param parent
+ * the parent composite
+ * @param toolkit
+ * the toolkit to use
+ */
+ private void createDetailsSection( Composite parent, FormToolkit toolkit )
+ {
+ Section section = toolkit.createSection( parent, Section.DESCRIPTION | Section.TITLE_BAR );
+ section.marginWidth = 10;
+ section.setText( "Partition Details" ); //$NON-NLS-1$
+ section.setDescription( "Set the properties of the partition." ); //$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 );
+ client.setLayout( glayout );
+ section.setClient( client );
+
+ // ID
+ toolkit.createLabel( client, "ID:" );
+ idText = toolkit.createText( client, "" );
+ idText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+
+ // Cache Size
+ toolkit.createLabel( client, "Cache Size:" );
+ cacheSizeText = toolkit.createText( client, "" );
+ cacheSizeText.addVerifyListener( new VerifyListener()
+ {
+ public void verifyText( VerifyEvent e )
+ {
+ if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
+ {
+ e.doit = false;
+ }
+ }
+ } );
+ cacheSizeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+
+ // Suffix
+ toolkit.createLabel( client, "Suffix:" );
+ suffixText = toolkit.createText( client, "" );
+ suffixText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+
+ // Enable Optimizer
+ enableOptimizerCheckbox = toolkit.createButton( client, "Enable optimizer", SWT.CHECK );
+ enableOptimizerCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 3, 1 ) );
+
+ // Synchronisation On Write
+ synchOnWriteCheckbox = toolkit.createButton( client, "Synchronization on write", SWT.CHECK );
+ synchOnWriteCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 3, 1 ) );
+ }
+
+
+ /**
+ * Creates the Context Entry Section.
+ *
+ * @param parent
+ * the parent composite
+ * @param toolkit
+ * the toolkit to use
+ */
+ private void createContextEntrySection( Composite parent, FormToolkit toolkit )
+ {
+ Section section = toolkit.createSection( parent, Section.DESCRIPTION | Section.TITLE_BAR );
+ section.marginWidth = 10;
+ section.setText( "Context Entry" ); //$NON-NLS-1$
+ section.setDescription( "Set the attribute/value pairs for the Context Entry of the partition." ); //$NON-NLS-1$
+ section.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
+ Composite client = toolkit.createComposite( section );
+ toolkit.paintBordersFor( client );
+ client.setLayout( new GridLayout( 2, false ) );
+ section.setClient( client );
+
+ contextEntryTable = toolkit.createTable( client, SWT.NONE );
+ GridData gd = new GridData( SWT.FILL, SWT.NONE, true, false, 1, 3 );
+ 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 IStructuredContentProvider()
+ {
+ public Object[] getElements( Object inputElement )
+ {
+ List<AttributeValueObject> elements = new ArrayList<AttributeValueObject>();
+
+ Attributes attributes = ( Attributes ) inputElement;
+
+ NamingEnumeration<? extends Attribute> 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;
+
+ contextEntryAddButton = toolkit.createButton( client, "Add...", SWT.PUSH );
+ contextEntryAddButton.setLayoutData( buttonsGD );
+
+ contextEntryEditButton = toolkit.createButton( client, "Edit...", SWT.PUSH );
+ contextEntryEditButton.setEnabled( false );
+ contextEntryEditButton.setLayoutData( buttonsGD );
+
+ contextEntryDeleteButton = toolkit.createButton( client, "Delete", SWT.PUSH );
+ contextEntryDeleteButton.setEnabled( false );
+ contextEntryDeleteButton.setLayoutData( buttonsGD );
+ }
+
+
+ /**
+ * Creates the Indexed Attributes Section
+ *
+ * @param parent
+ * the parent composite
+ * @param toolkit
+ * the toolkit to use
+ */
+ private void createIndexedAttributesSection( Composite parent, FormToolkit toolkit )
+ {
+ Section indexedAttributesSection = toolkit.createSection( parent, Section.DESCRIPTION | Section.TITLE_BAR );
+ indexedAttributesSection.marginWidth = 10;
+ indexedAttributesSection.setText( "Indexed Attributes" ); //$NON-NLS-1$
+ indexedAttributesSection.setDescription( "Set the indexed attributes of the partition." ); //$NON-NLS-1$
+ indexedAttributesSection.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
+ Composite indexedAttributesClient = toolkit.createComposite( indexedAttributesSection );
+ toolkit.paintBordersFor( indexedAttributesClient );
+ indexedAttributesClient.setLayout( new GridLayout( 2, false ) );
+ indexedAttributesSection.setClient( indexedAttributesClient );
+
+ Table indexedAttributesTable = toolkit.createTable( indexedAttributesClient, SWT.NONE );
+ GridData gd = new GridData( SWT.FILL, SWT.NONE, true, false, 1, 3 );
+ gd.heightHint = 80;
+ indexedAttributesTable.setLayoutData( gd );
+ indexedAttributesTableViewer = new TableViewer( indexedAttributesTable );
+ indexedAttributesTableViewer.setContentProvider( new ArrayContentProvider() );
+ indexedAttributesTableViewer.setLabelProvider( new LabelProvider() );
+
+ GridData buttonsGD = new GridData( SWT.FILL, SWT.BEGINNING, false, false );
+ buttonsGD.widthHint = IDialogConstants.BUTTON_WIDTH;
+
+ indexedAttributeAddButton = toolkit.createButton( indexedAttributesClient, "Add...", SWT.PUSH );
+ indexedAttributeAddButton.setLayoutData( buttonsGD );
+
+ indexedAttributeEditButton = toolkit.createButton( indexedAttributesClient, "Edit...", SWT.PUSH );
+ indexedAttributeEditButton.setEnabled( false );
+ indexedAttributeEditButton.setLayoutData( buttonsGD );
+
+ indexedAttributeDeleteButton = toolkit.createButton( indexedAttributesClient, "Delete", SWT.PUSH );
+ indexedAttributeDeleteButton.setEnabled( false );
+ indexedAttributeDeleteButton.setLayoutData( buttonsGD );
+ }
+
+
+ /**
+ * Adds listeners to UI fields.
+ */
+ private void addListeners()
+ {
+ idText.addModifyListener( textModifyListener );
+ cacheSizeText.addModifyListener( textModifyListener );
+ suffixText.addModifyListener( textModifyListener );
+ enableOptimizerCheckbox.addSelectionListener( checkboxSelectionListener );
+ synchOnWriteCheckbox.addSelectionListener( checkboxSelectionListener );
+
+ contextEntryTableViewer.addDoubleClickListener( contextEntryTableViewerDoubleClickListener );
+ contextEntryTableViewer.addSelectionChangedListener( contextEntryTableViewerListener );
+ contextEntryAddButton.addSelectionListener( contextEntryAddButtonListener );
+ contextEntryEditButton.addSelectionListener( contextEntryEditButtonListener );
+ contextEntryDeleteButton.addSelectionListener( contextEntryDeleteButtonListener );
+
+ indexedAttributesTableViewer.addSelectionChangedListener( indexedAttributesTableViewerListener );
+ indexedAttributesTableViewer.addDoubleClickListener( indexedAttributesTableViewerDoubleClickListener );
+ indexedAttributeAddButton.addSelectionListener( indexedAttributeAddButtonListener );
+ indexedAttributeEditButton.addSelectionListener( indexedAttributeEditButtonListener );
+ indexedAttributeDeleteButton.addSelectionListener( indexedAttributeDeleteButtonListener );
+ }
+
+
+ /**
+ * Removes listeners to UI fields.
+ */
+ private void removeListeners()
+ {
+ idText.removeModifyListener( textModifyListener );
+ cacheSizeText.removeModifyListener( textModifyListener );
+ suffixText.removeModifyListener( textModifyListener );
+ enableOptimizerCheckbox.removeSelectionListener( checkboxSelectionListener );
+ synchOnWriteCheckbox.removeSelectionListener( checkboxSelectionListener );
+
+ contextEntryTableViewer.removeDoubleClickListener( contextEntryTableViewerDoubleClickListener );
+ contextEntryTableViewer.removeSelectionChangedListener( contextEntryTableViewerListener );
+ contextEntryAddButton.removeSelectionListener( contextEntryAddButtonListener );
+ contextEntryEditButton.removeSelectionListener( contextEntryEditButtonListener );
+ contextEntryDeleteButton.removeSelectionListener( contextEntryDeleteButtonListener );
+
+ indexedAttributesTableViewer.removeSelectionChangedListener( indexedAttributesTableViewerListener );
+ indexedAttributesTableViewer.removeDoubleClickListener( indexedAttributesTableViewerDoubleClickListener );
+ indexedAttributeAddButton.removeSelectionListener( indexedAttributeAddButtonListener );
+ indexedAttributeEditButton.removeSelectionListener( indexedAttributeEditButtonListener );
+ indexedAttributeDeleteButton.removeSelectionListener( indexedAttributeDeleteButtonListener );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.IPartSelectionListener#selectionChanged(org.eclipse.ui.forms.IFormPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged( IFormPart part, ISelection selection )
+ {
+ IStructuredSelection ssel = ( IStructuredSelection ) selection;
+ if ( ssel.size() == 1 )
+ {
+ input = ( Partition ) ssel.getFirstElement();
+ }
+ else
+ {
+ input = null;
+ }
+ refresh();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.IFormPart#commit(boolean)
+ */
+ public void commit( boolean onSave )
+ {
+ if ( input != null )
+ {
+ input.setId( idText.getText() );
+ input.setCacheSize( Integer.parseInt( cacheSizeText.getText() ) );
+ input.setSuffix( suffixText.getText() );
+ input.setEnableOptimizer( enableOptimizerCheckbox.getSelection() );
+ input.setSynchronizationOnWrite( synchOnWriteCheckbox.getSelection() );
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.IFormPart#dispose()
+ */
+ public void dispose()
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.IManagedForm)
+ */
+ public void initialize( IManagedForm form )
+ {
+ this.mform = form;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.IFormPart#isDirty()
+ */
+ public boolean isDirty()
+ {
+ return dirty;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.IFormPart#isStale()
+ */
+ public boolean isStale()
+ {
+ return false;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.IFormPart#refresh()
+ */
+ public void refresh()
+ {
+ removeListeners();
+
+ // ID
+ String id = input.getId();
+ idText.setText( ( id == null ) ? "" : id );
+
+ // Cache Size
+ cacheSizeText.setText( "" + input.getCacheSize() );
+
+ // Suffix
+ String suffix = input.getSuffix();
+ suffixText.setText( ( suffix == null ) ? "" : suffix );
+
+ // Enable Optimizer
+ enableOptimizerCheckbox.setSelection( input.isEnableOptimizer() );
+
+ // Synchronization on write
+ synchOnWriteCheckbox.setSelection( input.isSynchronizationOnWrite() );
+
+ // Context Entry
+ contextEntry = input.getContextEntry();
+ contextEntryTableViewer.setInput( contextEntry );
+ resizeContextEntryTableColumnsToFit();
+
+ // Indexed Attributes
+ indexedAttributes = input.getIndexedAttributes();
+ indexedAttributesTableViewer.setInput( indexedAttributes );
+
+ addListeners();
+ }
+
+
+ /**
+ * 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()
+ */
+ public void setFocus()
+ {
+ idText.setFocus();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.IFormPart#setFormInput(java.lang.Object)
+ */
+ public boolean setFormInput( Object input )
+ {
+ return false;
+ }
+
+
+ /**
+ * Opens an Indexed Attribute Dialog with the selected Indexed Attribute in the
+ * Indexed Attributes Table Viewer.
+ */
+ private void editSelectedIndexedAttribute()
+ {
+ StructuredSelection selection = ( StructuredSelection ) indexedAttributesTableViewer.getSelection();
+ if ( !selection.isEmpty() )
+ {
+ IndexedAttribute indexedAttribute = ( IndexedAttribute ) selection.getFirstElement();
+
+ IndexedAttributeDialog dialog = new IndexedAttributeDialog( indexedAttribute );
+ if ( Dialog.OK == dialog.open() && dialog.isDirty() )
+ {
+ indexedAttributesTableViewer.refresh();
+ masterDetailsBlock.setEditorDirty();
+ dirty = true;
+ }
+ }
+ }
+
+
+ /**
+ * 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();
+ dirty = true;
+ }
+ }
+ }
+}
Added: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/PartitionsMasterDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/PartitionsMasterDetailsBlock.java?rev=656336&view=auto
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/PartitionsMasterDetailsBlock.java (added)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/PartitionsMasterDetailsBlock.java Wed May 14 10:21:46 2008
@@ -0,0 +1,322 @@
+/*
+ * 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.v151;
+
+
+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.editor.ServerConfigurationEditor;
+import org.apache.directory.studio.apacheds.configuration.model.v151.Partition;
+import org.apache.directory.studio.apacheds.configuration.model.v151.ServerConfigurationV151;
+import org.eclipse.jface.action.Action;
+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.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.ui.forms.DetailsPart;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.MasterDetailsBlock;
+import org.eclipse.ui.forms.SectionPart;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+
+
+/**
+ * This class represents the Partitions Master/Details Block used in the Partitions Page.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PartitionsMasterDetailsBlock extends MasterDetailsBlock
+{
+ /** The associated page */
+ private FormPage page;
+
+ /** The input Server Configuration */
+ private ServerConfigurationV151 serverConfiguration;
+
+ /** The Interceptors List */
+ private List<Partition> partitions;
+
+ /** The Details Page */
+ private PartitionDetailsPage detailsPage;
+
+ private static final String NEW_ID = "New Partition ";
+
+ // UI Fields
+ private TableViewer viewer;
+ private Button addButton;
+ private Button deleteButton;
+
+
+ /**
+ * Creates a new instance of PartitionsMasterDetailsBlock.
+ *
+ * @param page
+ * the associated page
+ */
+ public PartitionsMasterDetailsBlock( FormPage page )
+ {
+ this.page = page;
+ serverConfiguration = ( ServerConfigurationV151 ) ( ( ServerConfigurationEditor ) page.getEditor() ).getServerConfiguration();
+ partitions = serverConfiguration.getPartitions();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.MasterDetailsBlock#createMasterPart(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite)
+ */
+ protected void createMasterPart( final IManagedForm managedForm, Composite parent )
+ {
+ FormToolkit toolkit = managedForm.getToolkit();
+
+ // Creating the Section
+ Section section = toolkit.createSection( parent, Section.TITLE_BAR );
+ section.setText( "All Partitions" );
+ section.marginWidth = 10;
+ section.marginHeight = 5;
+ Composite client = toolkit.createComposite( section, SWT.WRAP );
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.makeColumnsEqualWidth = false;
+ layout.marginWidth = 2;
+ layout.marginHeight = 2;
+ client.setLayout( layout );
+ toolkit.paintBordersFor( client );
+ section.setClient( client );
+
+ // Creatig the Table and Table Viewer
+ 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 TableViewer( table );
+ viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ managedForm.fireSelectionChanged( spart, event.getSelection() );
+ }
+ } );
+ viewer.setContentProvider( new ArrayContentProvider() );
+ viewer.setLabelProvider( new LabelProvider()
+ {
+ public Image getImage( Object element )
+ {
+
+ return ApacheDSConfigurationPlugin.getDefault().getImage(
+ ( ( Partition ) element ).isSystemPartition() ? ApacheDSConfigurationPluginConstants.IMG_PARTITION_SYSTEM
+ : ApacheDSConfigurationPluginConstants.IMG_PARTITION );
+ }
+ } );
+
+ // Creating the button(s)
+ addButton = toolkit.createButton( client, "Add...", SWT.PUSH ); //$NON-NLS-1$
+ addButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+ deleteButton = toolkit.createButton( client, "Delete", SWT.PUSH );
+ deleteButton.setEnabled( false );
+ deleteButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+ initFromInput();
+ addListeners();
+ }
+
+
+ /**
+ * Initializes the page with the Editor input.
+ */
+ private void initFromInput()
+ {
+ viewer.setInput( partitions );
+ }
+
+
+ /**
+ * Add listeners to UI fields.
+ */
+ private void addListeners()
+ {
+ viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ 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 );
+ }
+ }
+ }
+ } );
+
+ addButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ Partition newPartition = new Partition( getNewId() );
+ partitions.add( newPartition );
+ viewer.refresh();
+ viewer.setSelection( new StructuredSelection( newPartition ) );
+ setEditorDirty();
+ }
+ } );
+
+ deleteButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+ if ( !selection.isEmpty() )
+ {
+ Partition partition = ( Partition ) selection.getFirstElement();
+ if ( !partition.isSystemPartition() )
+ {
+ partitions.remove( partition );
+ viewer.refresh();
+ setEditorDirty();
+ }
+ }
+ }
+ } );
+ }
+
+
+ /**
+ * Gets a new ID for a new Partition.
+ *
+ * @return
+ * a new ID for a new Partition
+ */
+ private String getNewId()
+ {
+ int counter = 1;
+ String name = NEW_ID;
+ boolean ok = false;
+
+ while ( !ok )
+ {
+ ok = true;
+ name = NEW_ID + counter;
+
+ for ( Partition partition : partitions )
+ {
+ if ( partition.getId().equalsIgnoreCase( name ) )
+ {
+ ok = false;
+ }
+ }
+ counter++;
+ }
+
+ return name;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.MasterDetailsBlock#createToolBarActions(org.eclipse.ui.forms.IManagedForm)
+ */
+ protected void createToolBarActions( IManagedForm managedForm )
+ {
+ final ScrolledForm form = managedForm.getForm();
+
+ // Horizontal layout Action
+ Action horizontalAction = new Action( "Horizontal layout", Action.AS_RADIO_BUTTON ) { //$NON-NLS-1$
+ public void run()
+ {
+ sashForm.setOrientation( SWT.HORIZONTAL );
+ form.reflow( true );
+ }
+ };
+ horizontalAction.setChecked( true );
+ horizontalAction.setToolTipText( "Horizontal Orientation" ); //$NON-NLS-1$
+ horizontalAction.setImageDescriptor( ApacheDSConfigurationPlugin.getDefault().getImageDescriptor(
+ ApacheDSConfigurationPluginConstants.IMG_HORIZONTAL_ORIENTATION ) );
+
+ // Vertical layout Action
+ Action verticalAction = new Action( "Vertical Orientation", Action.AS_RADIO_BUTTON ) { //$NON-NLS-1$
+ public void run()
+ {
+ sashForm.setOrientation( SWT.VERTICAL );
+ form.reflow( true );
+ }
+ };
+ verticalAction.setChecked( false );
+ verticalAction.setToolTipText( "Vertical Orientation" ); //$NON-NLS-1$
+ verticalAction.setImageDescriptor( ApacheDSConfigurationPlugin.getDefault().getImageDescriptor(
+ ApacheDSConfigurationPluginConstants.IMG_VERTICAL_ORIENTATION ) );
+
+ form.getToolBarManager().add( horizontalAction );
+ form.getToolBarManager().add( verticalAction );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.MasterDetailsBlock#registerPages(org.eclipse.ui.forms.DetailsPart)
+ */
+ protected void registerPages( DetailsPart detailsPart )
+ {
+ detailsPage = new PartitionDetailsPage( this );
+ detailsPart.registerPage( Partition.class, detailsPage );
+ }
+
+
+ /**
+ * Sets the Editor as dirty.
+ */
+ public void setEditorDirty()
+ {
+ ( ( ServerConfigurationEditor ) page.getEditor() ).setDirty( true );
+ }
+
+
+ /**
+ * Saves the necessary elements to the input model.
+ */
+ public void save()
+ {
+ detailsPage.commit( true );
+ viewer.setInput( partitions );
+ }
+}
Added: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/PartitionsPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/PartitionsPage.java?rev=656336&view=auto
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/PartitionsPage.java (added)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/PartitionsPage.java Wed May 14 10:21:46 2008
@@ -0,0 +1,83 @@
+/*
+ * 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.v151;
+
+
+import org.apache.directory.studio.apacheds.configuration.editor.SavableFormPage;
+import org.apache.directory.studio.apacheds.configuration.editor.ServerConfigurationEditor;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+
+/**
+ * This class represents the Partitions Page of the Server Configuration Editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PartitionsPage extends FormPage implements SavableFormPage
+{
+ /** The Page ID*/
+ public static final String ID = ServerConfigurationEditor.ID + ".V151.PartitionsPage";
+
+ /** The Page Title */
+ private static final String TITLE = "Partitions";
+
+ /** The Master/Details block */
+ private PartitionsMasterDetailsBlock masterDetailsBlock;
+
+
+ /**
+ * Creates a new instance of PartitionsPage.
+ *
+ * @param editor
+ * the associated editor
+ */
+ public PartitionsPage( FormEditor editor )
+ {
+ super( editor, ID, TITLE );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
+ */
+ protected void createFormContent( IManagedForm managedForm )
+ {
+ ScrolledForm form = managedForm.getForm();
+ form.setText( "Partitions" );
+ masterDetailsBlock = new PartitionsMasterDetailsBlock( this );
+ masterDetailsBlock.createContent( managedForm );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.configuration.editor.SavableWizardPage#save()
+ */
+ public void save()
+ {
+ if ( masterDetailsBlock != null )
+ {
+ masterDetailsBlock.save();
+ }
+ }
+}
Added: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/dialogs/AttributeValueDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/dialogs/AttributeValueDialog.java?rev=656336&view=auto
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/dialogs/AttributeValueDialog.java (added)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/dialogs/AttributeValueDialog.java Wed May 14 10:21:46 2008
@@ -0,0 +1,175 @@
+/*
+ * 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.v151.dialogs;
+
+
+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 <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @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;
+ }
+}
Added: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/dialogs/AttributeValueObject.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/dialogs/AttributeValueObject.java?rev=656336&view=auto
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/dialogs/AttributeValueObject.java (added)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/dialogs/AttributeValueObject.java Wed May 14 10:21:46 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.editor.v151.dialogs;
+
+
+/**
+ * This class implements an Attribute Value Object that is used in the PartitionDetailsPage.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @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 + "\"";
+ }
+}
Added: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/dialogs/BinaryAttributeDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/dialogs/BinaryAttributeDialog.java?rev=656336&view=auto
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/dialogs/BinaryAttributeDialog.java (added)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/dialogs/BinaryAttributeDialog.java Wed May 14 10:21:46 2008
@@ -0,0 +1,158 @@
+/*
+ * 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.v151.dialogs;
+
+
+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 Binary Attribute.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BinaryAttributeDialog extends Dialog
+{
+ /** The initial value */
+ private String initialValue;
+
+ /** The return value */
+ private String returnValue;
+
+ /** The dirty flag */
+ private boolean dirty = false;
+
+ // UI Fields
+ private Text attributeText;
+
+
+ /**
+ * Creates a new instance of AttributeValueDialog.
+ */
+ public BinaryAttributeDialog( String initialValue )
+ {
+ super( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
+ this.initialValue = initialValue;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell( Shell newShell )
+ {
+ super.configureShell( newShell );
+ newShell.setText( "Binary Attribute 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 ) );
+
+ initFromInput();
+ addListeners();
+
+ return composite;
+ }
+
+
+ /**
+ * Initializes the UI from the input.
+ */
+ private void initFromInput()
+ {
+ attributeText.setText( ( initialValue == null ) ? "" : initialValue );
+ }
+
+
+ /**
+ * Adds listeners to the UI Fields.
+ */
+ private void addListeners()
+ {
+ attributeText.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ dirty = true;
+ }
+ } );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed()
+ {
+ returnValue = attributeText.getText();
+
+ super.okPressed();
+ }
+
+
+ /**
+ * Gets the Attribute.
+ *
+ * @return
+ * the Attribute
+ */
+ public String getAttribute()
+ {
+ return returnValue;
+ }
+
+
+ /**
+ * Returns the dirty flag of the dialog.
+ *
+ * @return
+ * the dirty flag of the dialog
+ */
+ public boolean isDirty()
+ {
+ return dirty;
+ }
+}
Added: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/dialogs/IndexedAttributeDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/dialogs/IndexedAttributeDialog.java?rev=656336&view=auto
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/dialogs/IndexedAttributeDialog.java (added)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/v151/dialogs/IndexedAttributeDialog.java Wed May 14 10:21:46 2008
@@ -0,0 +1,193 @@
+/*
+ * 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.v151.dialogs;
+
+
+import org.apache.directory.studio.apacheds.configuration.model.v151.IndexedAttribute;
+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.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+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 Indexed Attribute.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class IndexedAttributeDialog extends Dialog
+{
+ /** The Indexed Attribute */
+ private IndexedAttribute indexedAttribute;
+
+ /** The dirty flag */
+ private boolean dirty = false;
+
+ // UI Fields
+ private Text attributeIdText;
+ private Text cacheSizeText;
+
+
+ /**
+ * Creates a new instance of IndexedAttributeDialog.
+ */
+ public IndexedAttributeDialog( IndexedAttribute indexedAttribute )
+ {
+ super( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
+ this.indexedAttribute = indexedAttribute;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell( Shell newShell )
+ {
+ super.configureShell( newShell );
+ newShell.setText( "Indexed Attribute 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 attributeIdLabel = new Label( composite, SWT.NONE );
+ attributeIdLabel.setText( "Attribute ID:" );
+
+ attributeIdText = new Text( composite, SWT.BORDER );
+ attributeIdText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ Label cacheSizeLabel = new Label( composite, SWT.NONE );
+ cacheSizeLabel.setText( "Cache Size:" );
+
+ cacheSizeText = new Text( composite, SWT.BORDER );
+ cacheSizeText.addVerifyListener( new VerifyListener()
+ {
+ public void verifyText( VerifyEvent e )
+ {
+ if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
+ {
+ e.doit = false;
+ }
+ }
+ } );
+ cacheSizeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ initFromInput();
+ addListeners();
+
+ return composite;
+ }
+
+
+ /**
+ * Initializes the UI from the input.
+ */
+ private void initFromInput()
+ {
+ String attributeId = indexedAttribute.getAttributeId();
+ attributeIdText.setText( ( attributeId == null ) ? "" : attributeId );
+ cacheSizeText.setText( "" + indexedAttribute.getCacheSize() );
+ }
+
+
+ /**
+ * Adds listeners to the UI Fields.
+ */
+ private void addListeners()
+ {
+ attributeIdText.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ dirty = true;
+ }
+ } );
+
+ cacheSizeText.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ dirty = true;
+ }
+ } );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed()
+ {
+ indexedAttribute.setAttributeId( attributeIdText.getText() );
+ try
+ {
+ indexedAttribute.setCacheSize( Integer.parseInt( cacheSizeText.getText() ) );
+ }
+ catch ( NumberFormatException e )
+ {
+ // Nothing to do, it won't happen
+ }
+
+ super.okPressed();
+ }
+
+
+ /**
+ * Gets the Indexed Attribute.
+ *
+ * @return
+ * the Indexed Attribute
+ */
+ public IndexedAttribute getIndexedAttribute()
+ {
+ return indexedAttribute;
+ }
+
+
+ /**
+ * Returns the dirty flag of the dialog.
+ *
+ * @return
+ * the dirty flag of the dialog
+ */
+ public boolean isDirty()
+ {
+ return dirty;
+ }
+}