directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1032542 - in /directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor: PartitionDetailsPage.java PartitionsMasterDetailsBlock.java PartitionsPage.java
Date Mon, 08 Nov 2010 11:09:11 GMT
Author: pamarcelot
Date: Mon Nov  8 11:09:11 2010
New Revision: 1032542

URL: http://svn.apache.org/viewvc?rev=1032542&view=rev
Log:
Added UI for the partitions page.

Added:
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionDetailsPage.java
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsMasterDetailsBlock.java
Modified:
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsPage.java

Added: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionDetailsPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionDetailsPage.java?rev=1032542&view=auto
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionDetailsPage.java
(added)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionDetailsPage.java
Mon Nov  8 11:09:11 2010
@@ -0,0 +1,284 @@
+/*
+ *  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.v2.editor;
+
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+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.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+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>
+ */
+public class PartitionDetailsPage implements IDetailsPage
+{
+    /** The associated Master Details Block */
+    private PartitionsMasterDetailsBlock masterDetailsBlock;
+
+    /** The Managed Form */
+    private IManagedForm mform;
+
+    /** 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 TableViewer indexedAttributesTableViewer;
+    private Button indexedAttributeAddButton;
+    private Button indexedAttributeEditButton;
+    private Button indexedAttributeDeleteButton;
+
+
+    /**
+     * 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 );
+        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" );
+        section.setDescription( " Partitions Details Description" );
+        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, "" ); //$NON-NLS-1$
+        idText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+
+        // Cache Size
+        toolkit.createLabel( client, "Cache Size:" );
+        cacheSizeText = toolkit.createText( client, "" ); //$NON-NLS-1$
+        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:" ); //$NON-NLS-1$
+        suffixText = toolkit.createText( client, "" ); //$NON-NLS-1$
+        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 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" );
+        indexedAttributesSection.setDescription( "Indexed Attributes Description" );
+        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 );
+    }
+
+
+
+
+    /* (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 )
+    {
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.forms.IFormPart#commit(boolean)
+     */
+    public void commit( boolean onSave )
+    {
+    }
+
+
+    /* (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#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;
+    }
+
+
+    public void refresh()
+    {
+        // TODO Auto-generated method stub
+        
+    }
+}

Added: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsMasterDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsMasterDetailsBlock.java?rev=1032542&view=auto
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsMasterDetailsBlock.java
(added)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsMasterDetailsBlock.java
Mon Nov  8 11:09:11 2010
@@ -0,0 +1,164 @@
+/*
+ *  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.v2.editor;
+
+
+import org.apache.directory.studio.apacheds.configuration.v2.ApacheDS2ConfigurationPlugin;
+import org.apache.directory.studio.apacheds.configuration.v2.ApacheDS2ConfigurationPluginConstants;
+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.TableViewer;
+import org.eclipse.swt.SWT;
+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.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>
+ */
+public class PartitionsMasterDetailsBlock extends MasterDetailsBlock
+{
+    /** The associated page */
+    private FormPage page;
+
+    /** The Details Page */
+    private PartitionDetailsPage detailsPage;
+
+    // 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;
+    }
+
+
+    /* (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 ApacheDS2ConfigurationPlugin.getDefault().getImage(
+                    ApacheDS2ConfigurationPluginConstants.IMG_PARTITION );
+            };
+        } );
+
+        // Creating the button(s)
+        addButton = toolkit.createButton( client, "Add", SWT.PUSH );
+        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();
+    }
+
+
+    /**
+     * Initializes the page with the Editor input.
+     */
+    private void initFromInput()
+    {
+        viewer.setInput( new String[]
+            { "ou=system", "dc=example,dc=com" } );
+    }
+
+
+    /* (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( String.class, detailsPage );
+    }
+
+
+    @Override
+    protected void createToolBarActions( IManagedForm managedForm )
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+}

Modified: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsPage.java?rev=1032542&r1=1032541&r2=1032542&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsPage.java
(original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsPage.java
Mon Nov  8 11:09:11 2010
@@ -56,5 +56,7 @@ public class PartitionsPage extends Serv
      */
     protected void createFormContent( Composite parent, FormToolkit toolkit )
     {
+        PartitionsMasterDetailsBlock masterDetailsBlock = new PartitionsMasterDetailsBlock(
this );
+        masterDetailsBlock.createContent( getManagedForm() );
     }
 }



Mime
View raw message