directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r592087 [13/16] - in /directory/sandbox/felixk/studio-ldapbrowser-ui: ./ META-INF/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/directory/ src/main/java/org/apache/directory/studio/ src...
Date Mon, 05 Nov 2007 17:01:46 GMT
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationApplyOnWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationApplyOnWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationApplyOnWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationApplyOnWizardPage.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,321 @@
+/*
+ *  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.ldapbrowser.ui.wizards;
+
+
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.naming.InvalidNameException;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.apache.directory.studio.ldapbrowser.common.widgets.search.SearchPageWrapper;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection.ReferralHandlingMethod;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.wizard.WizardPage;
+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.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+
+
+public class BatchOperationApplyOnWizardPage extends WizardPage
+{
+
+    private String[] initCurrentSelectionTexts;
+
+    private LdapDN[][] initCurrentSelectionDns;
+
+    private ISearch initSearch;
+
+    private Button currentSelectionButton;
+
+    private Combo currentSelectionCombo;
+
+    private Button searchButton;
+
+    private SearchPageWrapper spw;
+
+
+    public BatchOperationApplyOnWizardPage( String pageName, BatchOperationWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "Select Application Entries" );
+        super.setDescription( "Please select the entries where the batch operation should be applied to." );
+        super.setPageComplete( false );
+
+        this.prepareCurrentSelection();
+        this.prepareSearch();
+    }
+
+
+    private void validate()
+    {
+        setPageComplete( getApplyOnDns() != null || spw.isValid() );
+        setErrorMessage( searchButton.getSelection() ? spw.getErrorMessage() : null );
+    }
+
+
+    public void createControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        composite.setLayout( gl );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+        Composite applyOnGroup = composite;
+
+        this.currentSelectionButton = BaseWidgetUtils.createRadiobutton( applyOnGroup, "Current Selection:", 1 );
+        this.currentSelectionButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                enableCurrentSelectionWidgets( currentSelectionButton.getSelection() );
+                validate();
+            }
+        } );
+
+        Composite currentSelectionComposite = BaseWidgetUtils.createColumnContainer( applyOnGroup, 2, 1 );
+        BaseWidgetUtils.createRadioIndent( currentSelectionComposite, 1 );
+        this.currentSelectionCombo = BaseWidgetUtils.createReadonlyCombo( currentSelectionComposite,
+            this.initCurrentSelectionTexts, 0, 1 );
+        this.currentSelectionCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                validate();
+            }
+        } );
+
+        BaseWidgetUtils.createSpacer( applyOnGroup, 1 );
+        BaseWidgetUtils.createSpacer( applyOnGroup, 1 );
+
+        this.searchButton = BaseWidgetUtils.createRadiobutton( applyOnGroup, "Results of following Search:", 1 );
+        this.searchButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                enableSearchWidgets( searchButton.getSelection() );
+                validate();
+            }
+        } );
+
+        Composite searchComposite = BaseWidgetUtils.createColumnContainer( applyOnGroup, 2, 1 );
+        BaseWidgetUtils.createRadioIndent( searchComposite, 1 );
+        Composite innerSearchComposite = BaseWidgetUtils.createColumnContainer( searchComposite, 3, 1 );
+        this.spw = new SearchPageWrapper( SearchPageWrapper.NAME_INVISIBLE
+            | SearchPageWrapper.RETURNINGATTRIBUTES_INVISIBLE | SearchPageWrapper.REFERRALOPTIONS_READONLY );
+        this.spw.createContents( innerSearchComposite );
+        this.spw.loadFromSearch( this.initSearch );
+        this.spw.addWidgetModifyListener( new WidgetModifyListener()
+        {
+            public void widgetModified( WidgetModifyEvent event )
+            {
+                validate();
+            }
+        } );
+
+        this.currentSelectionButton.setSelection( this.currentSelectionCombo.getItemCount() > 0 );
+        this.currentSelectionButton.setEnabled( this.currentSelectionCombo.getItemCount() > 0 );
+        this.searchButton.setSelection( this.currentSelectionCombo.getItemCount() == 0 );
+        this.enableCurrentSelectionWidgets( this.currentSelectionButton.getSelection() );
+        this.enableSearchWidgets( this.searchButton.getSelection() );
+
+        validate();
+
+        setControl( composite );
+    }
+
+
+    public LdapDN[] getApplyOnDns()
+    {
+        if ( currentSelectionButton.getSelection() )
+        {
+            int index = currentSelectionCombo.getSelectionIndex();
+            return initCurrentSelectionDns[index];
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    public ISearch getApplyOnSearch()
+    {
+        if ( searchButton.getSelection() )
+        {
+            return this.initSearch;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    private void enableCurrentSelectionWidgets( boolean b )
+    {
+        currentSelectionCombo.setEnabled( b );
+    }
+
+
+    private void enableSearchWidgets( boolean b )
+    {
+        spw.setEnabled( b );
+    }
+
+
+    private void prepareSearch()
+    {
+        ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService()
+            .getSelection();
+        this.initSearch = BrowserSelectionUtils.getExampleSearch( selection );
+        this.initSearch.setName( null );
+
+        // never follow referrals for a batch operation!
+        this.initSearch.setReferralsHandlingMethod( ReferralHandlingMethod.IGNORE );
+    }
+
+
+    private void prepareCurrentSelection()
+    {
+
+        ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService()
+            .getSelection();
+        ISearch[] searches = BrowserSelectionUtils.getSearches( selection );
+        IEntry[] entries = BrowserSelectionUtils.getEntries( selection );
+        ISearchResult[] searchResults = BrowserSelectionUtils.getSearchResults( selection );
+        IBookmark[] bookmarks = BrowserSelectionUtils.getBookmarks( selection );
+        IAttribute[] attributes = BrowserSelectionUtils.getAttributes( selection );
+        IValue[] values = BrowserSelectionUtils.getValues( selection );
+
+        List<String> textList = new ArrayList<String>();
+        List<LdapDN[]> dnsList = new ArrayList<LdapDN[]>();
+
+        if ( attributes.length + values.length > 0 )
+        {
+            Set<LdapDN> internalDnSet = new LinkedHashSet<LdapDN>();
+            for ( int v = 0; v < values.length; v++ )
+            {
+                if ( values[v].isString() )
+                {
+                    try
+                    {
+                        LdapDN dn = new LdapDN( values[v].getStringValue() );
+                        internalDnSet.add( dn );
+                    }
+                    catch ( InvalidNameException e )
+                    {
+                    }
+                }
+            }
+
+            for ( int a = 0; a < attributes.length; a++ )
+            {
+                IValue[] vals = attributes[a].getValues();
+                for ( int v = 0; v < vals.length; v++ )
+                {
+                    if ( vals[v].isString() )
+                    {
+                        try
+                        {
+                            LdapDN dn = new LdapDN( vals[v].getStringValue() );
+                            internalDnSet.add( dn );
+                        }
+                        catch ( InvalidNameException e )
+                        {
+                        }
+                    }
+                }
+            }
+
+            if ( !internalDnSet.isEmpty() )
+            {
+                dnsList.add( internalDnSet.toArray( new LdapDN[internalDnSet.size()] ) );
+                textList.add( "DNs of selected Attributes (" + internalDnSet.size() + " Entries)" );
+            }
+        }
+        if ( searches.length == 1 && searches[0].getSearchResults() != null )
+        {
+            Set<LdapDN> internalDnSet = new LinkedHashSet<LdapDN>();
+            ISearchResult[] srs = searches[0].getSearchResults();
+            for ( int i = 0; i < srs.length; i++ )
+            {
+                internalDnSet.add( srs[i].getDn() );
+            }
+
+            dnsList.add( internalDnSet.toArray( new LdapDN[internalDnSet.size()] ) );
+            textList.add( "Search Results of '" + searches[0].getName() + "' (" + searches[0].getSearchResults().length
+                + " Entries)" );
+        }
+        if ( entries.length + searchResults.length + bookmarks.length > 0 )
+        {
+            Set<LdapDN> internalDnSet = new LinkedHashSet<LdapDN>();
+            for ( int i = 0; i < entries.length; i++ )
+            {
+                internalDnSet.add( entries[i].getDn() );
+            }
+            for ( int i = 0; i < searchResults.length; i++ )
+            {
+                internalDnSet.add( searchResults[i].getDn() );
+            }
+            for ( int i = 0; i < bookmarks.length; i++ )
+            {
+                internalDnSet.add( bookmarks[i].getDn() );
+            }
+
+            dnsList.add( internalDnSet.toArray( new LdapDN[internalDnSet.size()] ) );
+            textList.add( "Selected Entries (" + internalDnSet.size() + " Entries)" );
+        }
+
+        this.initCurrentSelectionTexts = textList.toArray( new String[textList.size()] );
+        this.initCurrentSelectionDns = dnsList.toArray( new LdapDN[0][0] );
+
+    }
+
+
+    public void saveDialogSettings()
+    {
+        this.spw.saveToSearch( initSearch );
+    }
+
+}
\ No newline at end of file

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationApplyOnWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationFinishWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationFinishWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationFinishWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationFinishWizardPage.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,115 @@
+/*
+ *  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.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class BatchOperationFinishWizardPage extends WizardPage
+{
+
+    public final static int EXECUTION_METHOD_NONE = -1;
+
+    public final static int EXECUTION_METHOD_LDIF = 0;
+
+    public final static int EXECUTION_METHOD_ONLINE = 1;
+
+    private Button executeOnlineButton;
+
+    private Button generateLdifButton;
+
+
+    public BatchOperationFinishWizardPage( String pageName, BatchOperationWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "Select Execution Method" );
+        super
+            .setDescription( "Please select if the batch operation should be executed online or a LDIF should be generated." );
+        super.setPageComplete( false );
+    }
+
+
+    private void validate()
+    {
+        setPageComplete( getExecutionMethod() != EXECUTION_METHOD_NONE );
+    }
+
+
+    public void createControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        composite.setLayout( gl );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+        generateLdifButton = BaseWidgetUtils.createRadiobutton( composite, "Generate LDIF", 1 );
+        generateLdifButton.setSelection( true );
+        generateLdifButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                validate();
+            }
+        } );
+
+        executeOnlineButton = BaseWidgetUtils.createRadiobutton( composite, "Excecute online", 1 );
+        executeOnlineButton.setEnabled( false );
+        executeOnlineButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                validate();
+            }
+        } );
+
+        validate();
+
+        setControl( composite );
+    }
+
+
+    public int getExecutionMethod()
+    {
+        if ( executeOnlineButton.getSelection() )
+        {
+            return EXECUTION_METHOD_ONLINE;
+        }
+        else if ( generateLdifButton.getSelection() )
+        {
+            return EXECUTION_METHOD_LDIF;
+        }
+        else
+        {
+            return EXECUTION_METHOD_NONE;
+        }
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationFinishWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationLdifWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationLdifWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationLdifWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationLdifWizardPage.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,147 @@
+/*
+ *  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.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.LdifFile;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifContainer;
+import org.apache.directory.studio.ldifeditor.widgets.LdifEditorWidget;
+
+import org.eclipse.jface.wizard.WizardPage;
+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.Composite;
+
+
+public class BatchOperationLdifWizardPage extends WizardPage implements WidgetModifyListener
+{
+
+    private static final String LDIF_DN_PREFIX = "dn: cn=dummy" + BrowserCoreConstants.LINE_SEPARATOR;
+
+    private static final String LDIF_INITIAL = "changetype: modify" + BrowserCoreConstants.LINE_SEPARATOR;
+
+    private BatchOperationWizard wizard;
+
+    private LdifEditorWidget ldifEditorWidget;
+
+
+    public BatchOperationLdifWizardPage( String pageName, BatchOperationWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "LDIF Fragment" );
+        super.setDescription( "Please enter the LDIF fragment that should be executed on each entry." );
+        // super.setImageDescriptor(BrowserUIPlugin.getDefault().getImageDescriptor(BrowserUIConstants.IMG_ENTRY_WIZARD));
+        super.setPageComplete( false );
+
+        this.wizard = wizard;
+    }
+
+
+    public void dispose()
+    {
+        ldifEditorWidget.dispose();
+        super.dispose();
+    }
+
+
+    private void validate()
+    {
+
+        LdifFile model = ldifEditorWidget.getLdifModel();
+        LdifContainer[] containers = model.getContainers();
+        if ( containers.length == 0 )
+        {
+            setPageComplete( false );
+            return;
+        }
+        for ( int i = 0; i < containers.length; i++ )
+        {
+            if ( !containers[i].isValid() )
+            {
+                setPageComplete( false );
+                return;
+            }
+        }
+
+        setPageComplete( true );
+
+    }
+
+
+    public boolean isPageComplete()
+    {
+
+        if ( wizard.getTypePage().getOperationType() != BatchOperationTypeWizardPage.OPERATION_TYPE_CREATE_LDIF )
+        {
+            return true;
+        }
+
+        return super.isPageComplete();
+    }
+
+
+    public void createControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        composite.setLayout( gl );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+        ldifEditorWidget = new LdifEditorWidget( null, LDIF_DN_PREFIX + LDIF_INITIAL, true );
+        ldifEditorWidget.createWidget( composite );
+        ldifEditorWidget.addWidgetModifyListener( this );
+
+        ldifEditorWidget.getSourceViewer().getTextWidget().addVerifyListener( new VerifyListener()
+        {
+            public void verifyText( VerifyEvent e )
+            {
+                if ( e.start < LDIF_DN_PREFIX.length() || e.end < LDIF_DN_PREFIX.length() )
+                {
+                    e.doit = false;
+                }
+            }
+        } );
+
+        validate();
+
+        setControl( composite );
+    }
+
+
+    public String getLdifFragment()
+    {
+        return ldifEditorWidget.getLdifModel().toRawString().replaceAll( LDIF_DN_PREFIX, "" );
+    }
+
+
+    public void widgetModified( WidgetModifyEvent event )
+    {
+        validate();
+    }
+
+}
\ No newline at end of file

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationLdifWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationModifyWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationModifyWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationModifyWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationModifyWizardPage.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,114 @@
+/*
+ *  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.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.ModWidget;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.LdifFile;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifContainer;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.parser.LdifParser;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class BatchOperationModifyWizardPage extends WizardPage implements WidgetModifyListener
+{
+
+    private BatchOperationWizard wizard;
+
+    private ModWidget modWidget;
+
+
+    public BatchOperationModifyWizardPage( String pageName, BatchOperationWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "Define Modification" );
+        super.setDescription( "Please define the modifcations." );
+        // super.setImageDescriptor(BrowserUIPlugin.getDefault().getImageDescriptor(BrowserUIConstants.IMG_ENTRY_WIZARD));
+        super.setPageComplete( false );
+
+        this.wizard = wizard;
+    }
+
+
+    private void validate()
+    {
+
+        String dummyLdif = "dn: cn=dummy" + BrowserCoreConstants.LINE_SEPARATOR + modWidget.getLdifFragment();
+        LdifFile model = new LdifParser().parse( dummyLdif );
+        LdifContainer[] containers = model.getContainers();
+        if ( containers.length == 0 )
+        {
+            setPageComplete( false );
+            return;
+        }
+        for ( int i = 0; i < containers.length; i++ )
+        {
+            if ( !containers[i].isValid() )
+            {
+                setPageComplete( false );
+                return;
+            }
+        }
+
+        setPageComplete( true );
+
+    }
+
+
+    public void createControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        composite.setLayout( gl );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+        modWidget = new ModWidget( wizard.getConnection() != null ? wizard.getConnection().getSchema()
+            : Schema.DEFAULT_SCHEMA );
+        modWidget.createContents( composite );
+        modWidget.addWidgetModifyListener( this );
+
+        validate();
+
+        setControl( composite );
+
+    }
+
+
+    public String getLdifFragment()
+    {
+        return modWidget.getLdifFragment();
+    }
+
+    public void widgetModified( WidgetModifyEvent event )
+    {
+        validate();
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationModifyWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationTypeWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationTypeWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationTypeWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationTypeWizardPage.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,116 @@
+/*
+ *  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.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class BatchOperationTypeWizardPage extends WizardPage
+{
+
+    public final static int OPERATION_TYPE_NONE = -1;
+
+    public final static int OPERATION_TYPE_MODIFY = 0;
+
+    public final static int OPERATION_TYPE_DELETE = 1;
+
+    public final static int OPERATION_TYPE_CREATE_LDIF = 2;
+
+    private final static String[] OPERATION_TYPES =
+        { "Modify entries", "Delete entries", "Execute LDIF changetype fragment on each entry" };
+
+    private Button[] operationTypeButtons;
+
+
+    public BatchOperationTypeWizardPage( String pageName, BatchOperationWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "Select Operation Type" );
+        super.setDescription( "Please select the batch operation type." );
+        super.setPageComplete( false );
+    }
+
+
+    private void validate()
+    {
+        setPageComplete( getOperationType() != OPERATION_TYPE_NONE );
+    }
+
+
+    public void createControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        composite.setLayout( gl );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+        operationTypeButtons = new Button[OPERATION_TYPES.length];
+        for ( int i = 0; i < operationTypeButtons.length; i++ )
+        {
+            operationTypeButtons[i] = BaseWidgetUtils.createRadiobutton( composite, OPERATION_TYPES[i], 1 );
+            operationTypeButtons[i].addSelectionListener( new SelectionListener()
+            {
+                public void widgetDefaultSelected( SelectionEvent e )
+                {
+                    validate();
+                }
+
+
+                public void widgetSelected( SelectionEvent e )
+                {
+                    validate();
+                }
+            } );
+        }
+        operationTypeButtons[0].setSelection( true );
+
+        validate();
+
+        setControl( composite );
+
+    }
+
+
+    public int getOperationType()
+    {
+
+        for ( int i = 0; i < operationTypeButtons.length; i++ )
+        {
+            if ( operationTypeButtons[i].getSelection() )
+            {
+                return i;
+            }
+        }
+
+        return OPERATION_TYPE_NONE;
+    }
+
+}
\ No newline at end of file

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationTypeWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationWizard.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationWizard.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationWizard.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,385 @@
+/*
+ *  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.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils;
+import org.apache.directory.studio.ldapbrowser.common.jobs.RunnableContextJobAdapter;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
+import org.apache.directory.studio.ldapbrowser.core.jobs.SearchJob;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.apache.directory.studio.ldifeditor.editor.LdifEditor;
+import org.apache.directory.studio.ldifeditor.editor.NonExistingLdifEditorInput;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+
+
+public class BatchOperationWizard extends Wizard implements INewWizard
+{
+
+    private IBrowserConnection connection;
+
+    private BatchOperationApplyOnWizardPage applyOnPage;
+
+    private BatchOperationTypeWizardPage typePage;
+
+    private BatchOperationLdifWizardPage ldifPage;
+
+    private BatchOperationModifyWizardPage modifyPage;
+
+    private BatchOperationFinishWizardPage finishPage;
+
+
+    public BatchOperationWizard()
+    {
+        super.setWindowTitle( "Batch Operation" );
+        super.setNeedsProgressMonitor( true );
+    }
+
+
+    public static String getId()
+    {
+        return BatchOperationWizard.class.getName();
+    }
+
+
+    public void init( IWorkbench workbench, IStructuredSelection selection )
+    {
+        // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection()
+    }
+
+
+    public void addPages()
+    {
+
+        ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService()
+            .getSelection();
+        Connection[] connections = BrowserSelectionUtils.getConnections( selection );
+        ISearch[] searches = BrowserSelectionUtils.getSearches( selection );
+        IEntry[] entries = BrowserSelectionUtils.getEntries( selection );
+        ISearchResult[] searchResults = BrowserSelectionUtils.getSearchResults( selection );
+        IBookmark[] bookmarks = BrowserSelectionUtils.getBookmarks( selection );
+        IAttribute[] attributes = BrowserSelectionUtils.getAttributes( selection );
+        IValue[] values = BrowserSelectionUtils.getValues( selection );
+
+        // if(searches.length + entries.length + searchResults.length +
+        // bookmarks.length > 0) {
+        if ( connections.length > 0
+            && connections[0].getJNDIConnectionWrapper().isConnected()
+            || searches.length + entries.length + searchResults.length + bookmarks.length + attributes.length
+                + values.length > 0 )
+        {
+
+            ISearch search = BrowserSelectionUtils.getExampleSearch( selection );
+            search.setName( null );
+            this.connection = search.getBrowserConnection();
+
+            applyOnPage = new BatchOperationApplyOnWizardPage( BatchOperationApplyOnWizardPage.class.getName(), this );
+            addPage( applyOnPage );
+
+            typePage = new BatchOperationTypeWizardPage( BatchOperationTypeWizardPage.class.getName(), this );
+            addPage( typePage );
+
+            ldifPage = new BatchOperationLdifWizardPage( BatchOperationLdifWizardPage.class.getName(), this );
+            addPage( ldifPage );
+
+            modifyPage = new BatchOperationModifyWizardPage( BatchOperationModifyWizardPage.class.getName(), this );
+            addPage( modifyPage );
+
+            finishPage = new BatchOperationFinishWizardPage( BatchOperationFinishWizardPage.class.getName(), this );
+            addPage( finishPage );
+        }
+        else
+        {
+            IWizardPage page = new DummyWizardPage();
+            addPage( page );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void createPageControls( Composite pageContainer )
+    {
+        super.createPageControls( pageContainer );
+        
+        // set help context ID
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( applyOnPage.getControl(),
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_batchoperation_wizard" );
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( typePage.getControl(),
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_batchoperation_wizard" );
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( ldifPage.getControl(),
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_batchoperation_wizard" );
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( modifyPage.getControl(),
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_batchoperation_wizard" );
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( finishPage.getControl(),
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_batchoperation_wizard" );
+    }
+
+
+    class DummyWizardPage extends WizardPage
+    {
+
+        protected DummyWizardPage()
+        {
+            super( "" );
+            super.setTitle( "No connection selected or connection is closed" );
+            super.setDescription( "In order to use the batch operation wizard please select a opened connection." );
+            // super.setImageDescriptor(BrowserUIPlugin.getDefault().getImageDescriptor(BrowserUIConstants.IMG_ENTRY_WIZARD));
+            super.setPageComplete( true );
+        }
+
+
+        public void createControl( Composite parent )
+        {
+            Composite composite = new Composite( parent, SWT.NONE );
+            GridLayout gl = new GridLayout( 1, false );
+            composite.setLayout( gl );
+            composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+            setControl( composite );
+        }
+    }
+
+
+    public IWizardPage getNextPage( IWizardPage page )
+    {
+
+        if ( this.applyOnPage != null )
+        {
+
+            if ( page == this.applyOnPage )
+            {
+                return this.typePage;
+            }
+
+            else if ( page == this.typePage
+                && this.typePage.getOperationType() == BatchOperationTypeWizardPage.OPERATION_TYPE_CREATE_LDIF )
+            {
+                return this.ldifPage;
+            }
+            else if ( page == this.typePage
+                && this.typePage.getOperationType() == BatchOperationTypeWizardPage.OPERATION_TYPE_MODIFY )
+            {
+                return this.modifyPage;
+            }
+            else if ( page == this.typePage
+                && this.typePage.getOperationType() == BatchOperationTypeWizardPage.OPERATION_TYPE_DELETE )
+            {
+                return this.finishPage;
+            }
+
+            else if ( page == this.modifyPage )
+            {
+                return this.finishPage;
+            }
+            else if ( page == this.ldifPage )
+            {
+                return this.finishPage;
+            }
+        }
+
+        return null;
+    }
+
+
+    public boolean canFinish()
+    {
+
+        if ( this.applyOnPage != null )
+        {
+            if ( !this.applyOnPage.isPageComplete() )
+            {
+                return false;
+            }
+            if ( !this.typePage.isPageComplete() )
+            {
+                return false;
+            }
+
+            if ( this.typePage.getOperationType() == BatchOperationTypeWizardPage.OPERATION_TYPE_CREATE_LDIF
+                && !this.ldifPage.isPageComplete() )
+            {
+                return false;
+            }
+            if ( this.typePage.getOperationType() == BatchOperationTypeWizardPage.OPERATION_TYPE_MODIFY
+                && !this.modifyPage.isPageComplete() )
+            {
+                return false;
+            }
+
+            if ( !this.finishPage.isPageComplete() )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+
+    public boolean performCancel()
+    {
+        return true;
+    }
+
+
+    public boolean performFinish()
+    {
+
+        if ( this.applyOnPage != null )
+        {
+
+            this.applyOnPage.saveDialogSettings();
+
+            // get LDIF
+            String ldifFragment = "";
+            if ( typePage.getOperationType() == BatchOperationTypeWizardPage.OPERATION_TYPE_CREATE_LDIF )
+            {
+                ldifFragment = this.ldifPage.getLdifFragment();
+            }
+            else if ( typePage.getOperationType() == BatchOperationTypeWizardPage.OPERATION_TYPE_MODIFY )
+            {
+                ldifFragment = this.modifyPage.getLdifFragment();
+            }
+            if ( typePage.getOperationType() == BatchOperationTypeWizardPage.OPERATION_TYPE_DELETE )
+            {
+                ldifFragment = "changetype: delete" + BrowserCoreConstants.LINE_SEPARATOR;
+            }
+
+            // get DNs
+            LdapDN[] dns = applyOnPage.getApplyOnDns();
+            if ( dns == null )
+            {
+                if ( applyOnPage.getApplyOnSearch() != null )
+                {
+                    ISearch search = applyOnPage.getApplyOnSearch();
+                    if ( search.getBrowserConnection() != null )
+                    {
+                        SearchJob job = new SearchJob( new ISearch[]
+                            { search } );
+                        RunnableContextJobAdapter.execute( job, getContainer() );
+                        if ( job.getExternalResult().isOK() )
+                        {
+                            ISearchResult[] srs = search.getSearchResults();
+                            dns = new LdapDN[srs.length];
+                            for ( int i = 0; i < srs.length; i++ )
+                            {
+                                dns[i] = srs[i].getDn();
+                            }
+                        }
+                    }
+                }
+            }
+
+            if ( dns != null )
+            {
+                StringBuffer ldif = new StringBuffer();
+                for ( int i = 0; i < dns.length; i++ )
+                {
+                    ldif.append( "dn: " );
+                    ldif.append( dns[i].getUpName() );
+                    ldif.append( BrowserCoreConstants.LINE_SEPARATOR );
+                    ldif.append( ldifFragment );
+                    ldif.append( BrowserCoreConstants.LINE_SEPARATOR );
+                }
+
+                if ( finishPage.getExecutionMethod() == BatchOperationFinishWizardPage.EXECUTION_METHOD_LDIF )
+                {
+
+                    IEditorInput input = new NonExistingLdifEditorInput();
+                    String editorId = LdifEditor.getId();
+
+                    try
+                    {
+                        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+                        IWorkbenchPage page = window.getActivePage();
+                        IEditorPart editor = page.openEditor( input, editorId );
+                        IDocumentProvider documentProvider = ( ( LdifEditor ) editor ).getDocumentProvider();
+                        if ( documentProvider != null && input != null )
+                        {
+                            IDocument document = documentProvider.getDocument( input );
+                            if ( document != null )
+                            {
+                                document.set( ldif.toString() );
+                            }
+                        }
+
+                    }
+                    catch ( PartInitException e )
+                    {
+                        return false;
+                    }
+                    return true;
+
+                }
+                else if ( finishPage.getExecutionMethod() == BatchOperationFinishWizardPage.EXECUTION_METHOD_ONLINE )
+                {
+                    // TODO
+                }
+            }
+
+            return false;
+        }
+
+        return true;
+    }
+
+
+    public BatchOperationTypeWizardPage getTypePage()
+    {
+        return typePage;
+    }
+
+
+    public IBrowserConnection getConnection()
+    {
+        return this.connection;
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseFromWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseFromWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseFromWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseFromWizardPage.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,110 @@
+/*
+ *  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.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.apache.directory.studio.ldapbrowser.common.widgets.search.SearchPageWrapper;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.widgets.Composite;
+
+
+/**
+ * This class is a base implementation of the page to select the data to export.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class ExportBaseFromWizardPage extends WizardPage implements WidgetModifyListener
+{
+
+    /** The wizard. */
+    protected ExportBaseWizard wizard;
+
+    /** The search page wrapper. */
+    protected SearchPageWrapper spw;
+
+
+    /**
+     * Creates a new instance of ExportBaseFromWizardPage.
+     * 
+     * @param spw the search page wrapper
+     * @param pageName the page name
+     * @param wizard the wizard
+     */
+    public ExportBaseFromWizardPage( String pageName, ExportBaseWizard wizard, SearchPageWrapper spw )
+    {
+        super( pageName );
+        setTitle( "Data to Export" );
+        setDescription( "Please define search parameters for the export." );
+        setPageComplete( true );
+
+        this.wizard = wizard;
+        this.spw = spw;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void createControl( Composite parent )
+    {
+        Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
+
+        spw.createContents( composite );
+        spw.loadFromSearch( wizard.getSearch() );
+        spw.addWidgetModifyListener( this );
+
+        setControl( composite );
+    }
+
+
+    /**
+     * Validates this page and sets the error message
+     * if this page is not valid.
+     */
+    protected void validate()
+    {
+        setPageComplete( spw.isValid() );
+        setErrorMessage( spw.getErrorMessage() );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void widgetModified( WidgetModifyEvent event )
+    {
+        validate();
+    }
+
+
+    /**
+     * Saves the dialog settings.
+     */
+    public void saveDialogSettings()
+    {
+        spw.saveToSearch( wizard.getSearch() );
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseFromWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseToPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseToPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseToPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseToPage.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,182 @@
+/*
+ *  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.ldapbrowser.ui.wizards;
+
+
+import java.io.File;
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.FileBrowserWidget;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+
+/**
+ * This class is a base implementation of the page to select the target export file.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class ExportBaseToPage extends WizardPage
+{
+
+    /** The wizard. */
+    protected ExportBaseWizard wizard;
+
+    /** The file browser widget. */
+    protected FileBrowserWidget fileBrowserWidget;
+
+    /** The overwrite file button. */
+    protected Button overwriteFileButton;
+
+
+    /**
+     * Creates a new instance of ExportBaseToPage.
+     * 
+     * @param pageName the page name
+     * @param wizard the wizard
+     */
+    public ExportBaseToPage( String pageName, ExportBaseWizard wizard )
+    {
+        super( pageName );
+        setPageComplete( false );
+        setTitle( getFileType() + " File" );
+        setDescription( "Please enter the target " + getFileType() + " file." );
+
+        this.wizard = wizard;
+    }
+
+
+    /**
+     * Validates this page. This method is responsible for displaying errors, 
+     * as well as enabling/disabling the "Finish" button
+     */
+    protected void validate()
+    {
+        boolean ok = true;
+        File file = new File( fileBrowserWidget.getFilename() );
+        File fileDirectory = file.getParentFile();
+        if ( "".equals( fileBrowserWidget.getFilename() ) )
+        {
+            setErrorMessage( null );
+            ok = false;
+        }
+        else if ( file.isDirectory() )
+        {
+            setErrorMessage( "Selected " + getFileType() + " is no file." );
+            ok = false;
+        }
+        else if ( file.exists() && !overwriteFileButton.getSelection() )
+        {
+            setErrorMessage( "Selected " + getFileType() + " file already exists. Select option 'Overwrite existing "
+                + getFileType() + " file' if you want to overwrite the " + getFileType() + " file." );
+            ok = false;
+        }
+        else if ( file.exists() && !file.canWrite() )
+        {
+            setErrorMessage( "Selected " + getFileType() + " file is not writeable." );
+            ok = false;
+        }
+        else if ( file.getParentFile() == null )
+        {
+            setErrorMessage( "Selected " + getFileType() + " file directory is not writeable." );
+            ok = false;
+        }
+        else if ( !file.exists() && ( fileDirectory == null || !fileDirectory.canWrite() ) )
+        {
+            setErrorMessage( "Selected " + getFileType() + " file directory is not writeable." );
+            ok = false;
+        }
+
+        if ( ok )
+        {
+            setErrorMessage( null );
+        }
+
+        setPageComplete( ok && wizard.getExportFilename() != null && !"".equals( wizard.getExportFilename() ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void createControl( Composite composite )
+    {
+        // Export file
+        BaseWidgetUtils.createLabel( composite, getFileType() + " File:", 1 );
+        fileBrowserWidget = new FileBrowserWidget( "Select " + getFileType() + " File", getExtensions(),
+            FileBrowserWidget.TYPE_SAVE );
+        fileBrowserWidget.createWidget( composite );
+        fileBrowserWidget.addWidgetModifyListener( new WidgetModifyListener()
+        {
+            public void widgetModified( WidgetModifyEvent event )
+            {
+                wizard.setExportFilename( fileBrowserWidget.getFilename() );
+                validate();
+            }
+        } );
+        BaseWidgetUtils.createRadioIndent( composite, 1 );
+        overwriteFileButton = BaseWidgetUtils.createCheckbox( composite, "O&verwrite existing " + getFileType()
+            + " file", 2 );
+        overwriteFileButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent event )
+            {
+                validate();
+            }
+        } );
+
+        fileBrowserWidget.setFocus();
+        setControl( composite );
+        validate();
+    }
+
+
+    /**
+     * Gets the valid file extensions.
+     * 
+     * @return the valid file extensions
+     */
+    protected abstract String[] getExtensions();
+
+
+    /**
+     * Gets the file type.
+     * 
+     * @return the file type
+     */
+    protected abstract String getFileType();
+
+
+    /**
+     * Saves the dialog settings.
+     */
+    public void saveDialogSettings()
+    {
+        fileBrowserWidget.saveDialogSettings();
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseToPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseWizard.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseWizard.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseWizard.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,117 @@
+/*
+ *  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.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IExportWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * This class is a base implementation of the export wizard.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class ExportBaseWizard extends Wizard implements IExportWizard
+{
+
+    /** The export filename. */
+    protected String exportFilename = "";
+
+    /** The search. */
+    protected ISearch search;
+
+
+    /**
+     * Creates a new instance of ExportBaseWizard.
+     * 
+     * @param title the title
+     */
+    public ExportBaseWizard( String title )
+    {
+        super();
+        setWindowTitle( title );
+        init( null, ( IStructuredSelection ) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService()
+            .getSelection() );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void init( IWorkbench workbench, IStructuredSelection selection )
+    {
+        search = BrowserSelectionUtils.getExampleSearch( selection );
+        search.setName( null );
+        exportFilename = "";
+    }
+
+
+    /**
+     * Sets the export filename.
+     * 
+     * @param exportFilename the export filename
+     */
+    public void setExportFilename( String exportFilename )
+    {
+        this.exportFilename = exportFilename;
+    }
+
+
+    /**
+     * Gets the export filename.
+     * 
+     * @return the export filename
+     */
+    public String getExportFilename()
+    {
+        return exportFilename;
+    }
+
+
+    /**
+     * Gets the search.
+     * 
+     * @return the search
+     */
+    public ISearch getSearch()
+    {
+        return search;
+    }
+
+
+    /**
+     * Sets the search.
+     * 
+     * @param search the search
+     */
+    public void setSearch( ISearch search )
+    {
+        this.search = search;
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvFromWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvFromWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvFromWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvFromWizardPage.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,70 @@
+/*
+ *  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.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.search.SearchPageWrapper;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+
+
+/**
+ * This class implements the page used to select the data to export to CSV.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExportCsvFromWizardPage extends ExportBaseFromWizardPage
+{
+
+    /**
+     * Creates a new instance of ExportExcelFromWizardPage using a 
+     * {@link SearchPageWrapper} with
+     * <ul> 
+     * <li>hidden name
+     * <li>visible and checked return DN checkbox
+     * <li>invisible all attributes checkbox
+     * <li>invisible operational attributes checkbox
+     * </ul> 
+     * 
+     * @param pageName the page name
+     * @param wizard the wizard
+     */
+    public ExportCsvFromWizardPage( String pageName, ExportBaseWizard wizard )
+    {
+        super( pageName, wizard, new SearchPageWrapper( SearchPageWrapper.NAME_INVISIBLE
+            | SearchPageWrapper.RETURN_DN_VISIBLE | SearchPageWrapper.RETURN_DN_CHECKED ) );
+        super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+            BrowserUIConstants.IMG_EXPORT_CSV_WIZARD ) );
+    }
+
+
+    /**
+     * Checks if the DNs should be exported.
+     * 
+     * @return true, if the DNs should be exported
+     */
+    public boolean isExportDn()
+    {
+        return spw.isReturnDn();
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvFromWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvToWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvToWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvToWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvToWizardPage.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,103 @@
+/*
+ *  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.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.studio.ldapbrowser.common.dialogs.preferences.TextFormatsPreferencePage;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+
+/**
+ * This class implements the page to select the target CSV file.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExportCsvToWizardPage extends ExportBaseToPage
+{
+
+    /** The extensions used by CSV files */
+    private static final String[] EXTENSIONS = new String[]
+        { "*.csv", "*.txt", "*.*" };
+
+
+    /**
+     * Creates a new instance of ExportCsvToWizardPage.
+     * 
+     * @param pageName the page name
+     * @param wizard the wizard
+     */
+    public ExportCsvToWizardPage( String pageName, ExportBaseWizard wizard )
+    {
+        super( pageName, wizard );
+        setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_CSV_WIZARD ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void createControl( Composite parent )
+    {
+        final Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
+        super.createControl( composite );
+
+        BaseWidgetUtils.createSpacer( composite, 3 );
+
+        BaseWidgetUtils.createSpacer( composite, 1 );
+        String text = "See <a>Text Formats</a> for CSV file format preferences.";
+        Link link = BaseWidgetUtils.createLink( composite, text, 2 );
+        link.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                PreferencesUtil.createPreferenceDialogOn( getShell(), TextFormatsPreferencePage.class.getName(), null,
+                    TextFormatsPreferencePage.CSV_TAB ).open();
+            }
+        } );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected String[] getExtensions()
+    {
+        return EXTENSIONS;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected String getFileType()
+    {
+        return "CSV";
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvToWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvWizard.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvWizard.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvWizard.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,109 @@
+/*
+ *  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.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.studio.ldapbrowser.core.jobs.ExportCsvJob;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * This class implements the Wizard for Exporting to CSV
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExportCsvWizard extends ExportBaseWizard
+{
+
+    /** The from page, used to select the exported data. */
+    private ExportCsvFromWizardPage fromPage;
+
+    /** The to page, used to select the target file. */
+    private ExportCsvToWizardPage toPage;
+
+
+    /**
+     * Creates a new instance of ExportCsvWizard.
+     */
+    public ExportCsvWizard()
+    {
+        super( "CSV Export" );
+    }
+
+
+    /**
+     * Gets the ID of the Export CSV Wizard
+     * 
+     * @return The ID of the Export CSV Wizard
+     */
+    public static String getId()
+    {
+        return ExportCsvWizard.class.getName();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addPages()
+    {
+        fromPage = new ExportCsvFromWizardPage( ExportCsvFromWizardPage.class.getName(), this );
+        addPage( fromPage );
+        toPage = new ExportCsvToWizardPage( ExportCsvToWizardPage.class.getName(), this );
+        addPage( toPage );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void createPageControls( Composite pageContainer )
+    {
+        super.createPageControls( pageContainer );
+
+        // set help context ID
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( fromPage.getControl(),
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_csvexport_wizard" );
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( toPage.getControl(),
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_csvexport_wizard" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean performFinish()
+    {
+        fromPage.saveDialogSettings();
+        toPage.saveDialogSettings();
+        boolean exportDn = this.fromPage.isExportDn();
+
+        ExportCsvJob ecj = new ExportCsvJob( exportFilename, search.getBrowserConnection(), search.getSearchParameter(),
+            exportDn );
+        ecj.execute();
+
+        return true;
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlFromWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlFromWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlFromWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlFromWizardPage.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,64 @@
+/*
+ *  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.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.search.SearchPageWrapper;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+
+
+/**
+ * This class implements the page used to select the data to export to DSML.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExportDsmlFromWizardPage extends ExportBaseFromWizardPage
+{
+
+    /**
+     * Creates a new instance of ExportDsmlFromWizardPage using a 
+     * {@link SearchPageWrapper} with
+     * <ul> 
+     * <li>hidden name
+     * <li>visible all attributes checkbox
+     * <li>visible operational attributes checkbox
+     * </ul> 
+     *
+     * @param pageName
+     *          the name of the page
+     * @param wizard
+     *          the wizard the page is attached to
+     */
+    public ExportDsmlFromWizardPage( String pageName, ExportBaseWizard wizard )
+    {
+        super( pageName, wizard, new SearchPageWrapper(
+            SearchPageWrapper.NAME_INVISIBLE
+                | SearchPageWrapper.RETURN_ALLATTRIBUTES_VISIBLE
+                | SearchPageWrapper.RETURN_OPERATIONALATTRIBUTES_VISIBLE
+                | ( ( wizard.getSearch().getReturningAttributes() == null || wizard.getSearch()
+                    .getReturningAttributes().length == 0 ) ? SearchPageWrapper.RETURN_ALLATTRIBUTES_CHECKED
+                    : SearchPageWrapper.NONE ) ) );
+        super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+            BrowserUIConstants.IMG_EXPORT_DSML_WIZARD ) );
+    }
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlFromWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlToWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlToWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlToWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlToWizardPage.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,85 @@
+/*
+ *  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.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.swt.widgets.Composite;
+
+
+/**
+ * This class implements the page to select the target DSML file.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExportDsmlToWizardPage extends ExportBaseToPage
+{
+    /** The extensions used by DSML files*/
+    private static final String[] EXTENSIONS = new String[]
+        { "*.xml", "*.*" };
+
+
+    /**
+     * Creates a new instance of ExportDsmlToWizardPage.
+     *
+     * @param pageName
+     *          the name of the page
+     * @param wizard
+     *          the wizard the page is attached to
+     */
+    public ExportDsmlToWizardPage( String pageName, ExportBaseWizard wizard )
+    {
+        super( pageName, wizard );
+        super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+            BrowserUIConstants.IMG_EXPORT_DSML_WIZARD ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void createControl( Composite parent )
+    {
+        final Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
+        super.createControl( composite );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected String[] getExtensions()
+    {
+        return EXTENSIONS;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected String getFileType()
+    {
+        return "DSML";
+    }
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlToWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlWizard.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlWizard.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlWizard.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,108 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.studio.ldapbrowser.core.jobs.ExportDsmlJob;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * This class implements the Wizard for Exporting to DSML
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExportDsmlWizard extends ExportBaseWizard
+{
+    
+    /** The title. */
+    public static final String WIZARD_TITLE = "DSML Export";
+
+    /** The from page, used to select the exported data. */
+    private ExportDsmlFromWizardPage fromPage;
+
+    /** The to page, used to select the target file. */
+    private ExportDsmlToWizardPage toPage;
+
+
+    /**
+     * Creates a new instance of ExportDsmlWizard.
+     */
+    public ExportDsmlWizard()
+    {
+        super( WIZARD_TITLE );
+    }
+
+
+    /**
+     * Gets the ID of the Export DSML Wizard
+     * @return The ID of the Export DSML Wizard
+     */
+    public static String getId()
+    {
+        return ExportDsmlWizard.class.getName();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addPages()
+    {
+        fromPage = new ExportDsmlFromWizardPage( ExportDsmlFromWizardPage.class.getName(), this );
+        addPage( fromPage );
+        toPage = new ExportDsmlToWizardPage( ExportDsmlToWizardPage.class.getName(), this );
+        addPage( toPage );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void createPageControls( Composite pageContainer )
+    {
+        super.createPageControls( pageContainer );
+
+        // set help context ID
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( fromPage.getControl(),
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_dsmlexport_wizard" );
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( toPage.getControl(),
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_dsmlexport_wizard" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean performFinish()
+    {
+        fromPage.saveDialogSettings();
+        toPage.saveDialogSettings();
+
+        ExportDsmlJob edj = new ExportDsmlJob( exportFilename, search.getBrowserConnection(), search.getSearchParameter() );
+        edj.execute();
+
+        return true;
+    }
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message