You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2006/12/18 18:57:49 UTC
svn commit: r488371 [11/14] - in /directory/sandbox/pamarcelot/ldapstudio:
ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/jobs/
ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/perspective/
ldapstudio-browser-u...
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationLdifWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationLdifWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationLdifWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationLdifWizardPage.java Mon Dec 18 09:57:38 2006
@@ -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.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifFile;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifContainer;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyEvent;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyListener;
+import org.apache.directory.ldapstudio.browser.ui.widgets.ldifeditor.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
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationModifyWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationModifyWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationModifyWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationModifyWizardPage.java Mon Dec 18 09:57:38 2006
@@ -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.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifFile;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifContainer;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.parser.LdifParser;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+import org.apache.directory.ldapstudio.browser.ui.widgets.ModWidget;
+
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+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 IPropertyChangeListener
+{
+
+ 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.addPropertyChangeListener( this );
+
+ validate();
+
+ setControl( composite );
+
+ }
+
+
+ public String getLdifFragment()
+ {
+ return modWidget.getLdifFragment();
+ }
+
+
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ this.validate();
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationTypeWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationTypeWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationTypeWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationTypeWizardPage.java Mon Dec 18 09:57:38 2006
@@ -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.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.ui.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
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationWizard.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationWizard.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationWizard.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
+import org.apache.directory.ldapstudio.browser.core.jobs.SearchJob;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IBookmark;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.actions.SelectionUtils;
+import org.apache.directory.ldapstudio.browser.ui.editors.ldif.LdifEditor;
+import org.apache.directory.ldapstudio.browser.ui.editors.ldif.NonExistingLdifEditorInput;
+import org.apache.directory.ldapstudio.browser.ui.jobs.RunnableContextJobAdapter;
+
+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 IConnection 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();
+ IConnection[] connections = SelectionUtils.getConnections( selection );
+ ISearch[] searches = SelectionUtils.getSearches( selection );
+ IEntry[] entries = SelectionUtils.getEntries( selection );
+ ISearchResult[] searchResults = SelectionUtils.getSearchResults( selection );
+ IBookmark[] bookmarks = SelectionUtils.getBookmarks( selection );
+ IAttribute[] attributes = SelectionUtils.getAttributes( selection );
+ IValue[] values = SelectionUtils.getValues( selection );
+
+ // if(searches.length + entries.length + searchResults.length +
+ // bookmarks.length > 0) {
+ if ( connections.length > 0
+ && connections[0].isOpened()
+ || searches.length + entries.length + searchResults.length + bookmarks.length + attributes.length
+ + values.length > 0 )
+ {
+
+ ISearch search = SelectionUtils.getExampleSearch( selection );
+ search.setName( null );
+ this.connection = search.getConnection();
+
+ 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 );
+ }
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( getContainer().getShell(),
+ 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
+ DN[] dns = applyOnPage.getApplyOnDns();
+ if ( dns == null )
+ {
+ if ( applyOnPage.getApplyOnSearch() != null )
+ {
+ ISearch search = applyOnPage.getApplyOnSearch();
+ if ( search.getConnection() != null )
+ {
+ SearchJob job = new SearchJob( new ISearch[]
+ { search } );
+ RunnableContextJobAdapter.execute( job, getContainer() );
+ if ( job.getExternalResult().isOK() )
+ {
+ ISearchResult[] srs = search.getSearchResults();
+ dns = new DN[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].toString() );
+ 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 IConnection getConnection()
+ {
+ return this.connection;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportBaseFromWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportBaseFromWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportBaseFromWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportBaseFromWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyEvent;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyListener;
+import org.apache.directory.ldapstudio.browser.ui.widgets.search.SearchPageWrapper;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.widgets.Composite;
+
+
+public abstract class ExportBaseFromWizardPage extends WizardPage implements WidgetModifyListener
+{
+
+ protected ExportBaseWizard wizard;
+
+ protected SearchPageWrapper spw;
+
+
+ public ExportBaseFromWizardPage( String pageName, ExportBaseWizard wizard, SearchPageWrapper spw )
+ {
+ super( pageName );
+ super.setTitle( "Data to Export" );
+ super.setDescription( "Please define search parameters for the export." );
+ super.setPageComplete( true );
+
+ this.wizard = wizard;
+ this.spw = spw;
+ }
+
+
+ public void createControl( Composite parent )
+ {
+
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
+
+ this.spw.createContents( composite );
+ this.spw.loadFromSearch( wizard.getSearch() );
+ this.spw.addWidgetModifyListener( this );
+
+ setControl( composite );
+ // this.spw.setFocus();
+ }
+
+
+ public void setVisible( boolean visible )
+ {
+ super.setVisible( visible );
+ }
+
+
+ protected void validate()
+ {
+ setPageComplete( spw.isValid() );
+ }
+
+
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ validate();
+ }
+
+
+ public void saveDialogSettings()
+ {
+ this.spw.saveToSearch( wizard.getSearch() );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportBaseToPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportBaseToPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportBaseToPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportBaseToPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import java.io.File;
+
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.FileBrowserWidget;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyEvent;
+import org.apache.directory.ldapstudio.browser.ui.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;
+
+
+public abstract class ExportBaseToPage extends WizardPage
+{
+
+ protected ExportBaseWizard wizard;
+
+ protected FileBrowserWidget fileBrowserWidget;
+
+ protected Button overwriteFileButton;
+
+
+ public ExportBaseToPage( String pageName, ExportBaseWizard wizard )
+ {
+ super( pageName );
+ super.setPageComplete( false );
+ super.setTitle( getFileType() + " File" );
+ super.setDescription( "Please enter the target " + getFileType() + " file." );
+
+ this.wizard = wizard;
+ }
+
+
+ public void setVisible( boolean visible )
+ {
+ super.setVisible( visible );
+ }
+
+
+ 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() && !this.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() ) );
+ }
+
+
+ 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();
+ }
+
+
+ protected abstract String[] getExtensions();
+
+
+ protected abstract String getFileType();
+
+
+ public void saveDialogSettings()
+ {
+ this.fileBrowserWidget.saveDialogSettings();
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportBaseWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportBaseWizard.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportBaseWizard.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportBaseWizard.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.ui.actions.SelectionUtils;
+
+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;
+
+
+public abstract class ExportBaseWizard extends Wizard implements IExportWizard
+{
+
+ protected String exportFilename = "";
+
+ protected ISearch search;
+
+
+ public ExportBaseWizard( String title )
+ {
+ super();
+ super.setWindowTitle( title );
+ init( null, ( IStructuredSelection ) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService()
+ .getSelection() );
+ }
+
+
+ public void init( IWorkbench workbench, IStructuredSelection selection )
+ {
+ this.search = SelectionUtils.getExampleSearch( selection );
+ this.search.setName( null );
+ this.exportFilename = "";
+ }
+
+
+ public void setExportFilename( String exportFilename )
+ {
+ this.exportFilename = exportFilename;
+ }
+
+
+ public String getExportFilename()
+ {
+ return exportFilename;
+ }
+
+
+ public ISearch getSearch()
+ {
+ return search;
+ }
+
+
+ public void setSearch( ISearch search )
+ {
+ this.search = search;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportCsvFromWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportCsvFromWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportCsvFromWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportCsvFromWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.search.SearchPageWrapper;
+
+
+public class ExportCsvFromWizardPage extends ExportBaseFromWizardPage
+{
+
+ public ExportCsvFromWizardPage( String pageName, ExportBaseWizard wizard )
+ {
+ super( pageName, wizard, new SearchPageWrapper( SearchPageWrapper.NAME_INVISIBLE | SearchPageWrapper.DN_VISIBLE
+ | SearchPageWrapper.DN_CHECKED ) );
+ super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+ BrowserUIConstants.IMG_EXPORT_CSV_WIZARD ) );
+ }
+
+
+ public boolean isExportDn()
+ {
+ return spw.isExportDn();
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportCsvToWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportCsvToWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportCsvToWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportCsvToWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.preferences.TextFormatsPreferencePage;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+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;
+
+
+public class ExportCsvToWizardPage extends ExportBaseToPage
+{
+
+ private static final String[] EXTENSIONS = new String[]
+ { "*.csv", "*.txt", "*.*" };
+
+
+ public ExportCsvToWizardPage( String pageName, ExportBaseWizard wizard )
+ {
+ super( pageName, wizard );
+ super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+ BrowserUIConstants.IMG_EXPORT_CSV_WIZARD ) );
+ }
+
+
+ public void createControl( Composite parent )
+ {
+ // wizard.getContainer().getShell().setSize(convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH),
+ // convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH));
+ 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();
+ }
+ } );
+
+ }
+
+
+ protected static char getChar( String s )
+ {
+ return s != null && s.length() > 0 ? s.charAt( 0 ) : '\u0000';
+ }
+
+
+ protected String[] getExtensions()
+ {
+ return EXTENSIONS;
+ }
+
+
+ protected String getFileType()
+ {
+ return "CSV";
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportCsvWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportCsvWizard.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportCsvWizard.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportCsvWizard.java Mon Dec 18 09:57:38 2006
@@ -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.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.jobs.ExportCsvJob;
+
+
+public class ExportCsvWizard extends ExportBaseWizard
+{
+
+ private ExportCsvFromWizardPage fromPage;
+
+ private ExportCsvToWizardPage toPage;
+
+
+ public ExportCsvWizard()
+ {
+ super( "CSV Export" );
+ }
+
+
+ public static String getId()
+ {
+ return ExportCsvWizard.class.getName();
+ }
+
+
+ public void addPages()
+ {
+ fromPage = new ExportCsvFromWizardPage( ExportCsvFromWizardPage.class.getName(), this );
+ addPage( fromPage );
+ toPage = new ExportCsvToWizardPage( ExportCsvToWizardPage.class.getName(), this );
+ addPage( toPage );
+ }
+
+
+ public boolean performFinish()
+ {
+
+ this.fromPage.saveDialogSettings();
+ this.toPage.saveDialogSettings();
+ boolean exportDn = this.fromPage.isExportDn();
+
+ ExportCsvJob ecj = new ExportCsvJob( this.exportFilename, this.search.getConnection(), this.search
+ .getSearchParameter(), exportDn );
+ ecj.execute();
+
+ return true;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportExcelFromWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportExcelFromWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportExcelFromWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportExcelFromWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.search.SearchPageWrapper;
+
+
+public class ExportExcelFromWizardPage extends ExportBaseFromWizardPage
+{
+
+ public ExportExcelFromWizardPage( String pageName, ExportBaseWizard wizard )
+ {
+ super( pageName, wizard, new SearchPageWrapper(
+ SearchPageWrapper.NAME_INVISIBLE
+ | SearchPageWrapper.DN_VISIBLE
+ | SearchPageWrapper.DN_CHECKED
+ | SearchPageWrapper.ALLATTRIBUTES_VISIBLE
+ | SearchPageWrapper.OPERATIONALATTRIBUTES_VISIBLE
+ | ( ( wizard.getSearch().getReturningAttributes() == null || wizard.getSearch()
+ .getReturningAttributes().length == 0 ) ? SearchPageWrapper.ALLATTRIBUTES_CHECKED
+ : SearchPageWrapper.NONE ) ) );
+ super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+ BrowserUIConstants.IMG_EXPORT_XLS_WIZARD ) );
+ }
+
+
+ public boolean isExportDn()
+ {
+ return spw.isExportDn();
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportExcelToWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportExcelToWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportExcelToWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportExcelToWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.preferences.TextFormatsPreferencePage;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+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;
+
+
+public class ExportExcelToWizardPage extends ExportBaseToPage
+{
+
+ private static final String[] EXTENSIONS = new String[]
+ { "*.xls", "*.*" };
+
+
+ public ExportExcelToWizardPage( String pageName, ExportBaseWizard wizard )
+ {
+ super( pageName, wizard );
+ super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+ BrowserUIConstants.IMG_EXPORT_XLS_WIZARD ) );
+ }
+
+
+ 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 Excel 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.XLS_TAB ).open();
+ }
+ } );
+
+ BaseWidgetUtils.createSpacer( composite, 3 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createWrappedLabel( composite,
+ "Warning: Excel export is memory intensive! Maximum number of exportable entries is limited to 65000!", 2 );
+
+ }
+
+
+ protected static char getChar( String s )
+ {
+ return s != null && s.length() > 0 ? s.charAt( 0 ) : '\u0000';
+ }
+
+
+ protected String[] getExtensions()
+ {
+ return EXTENSIONS;
+ }
+
+
+ protected String getFileType()
+ {
+ return "Excel";
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportExcelWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportExcelWizard.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportExcelWizard.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportExcelWizard.java Mon Dec 18 09:57:38 2006
@@ -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.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.jobs.ExportXlsJob;
+
+
+public class ExportExcelWizard extends ExportBaseWizard
+{
+
+ private ExportExcelFromWizardPage fromPage;
+
+ private ExportExcelToWizardPage toPage;
+
+
+ public ExportExcelWizard()
+ {
+ super( "Excel Export" );
+ }
+
+
+ public static String getId()
+ {
+ return ExportExcelWizard.class.getName();
+ }
+
+
+ public void addPages()
+ {
+ fromPage = new ExportExcelFromWizardPage( ExportExcelFromWizardPage.class.getName(), this );
+ addPage( fromPage );
+ toPage = new ExportExcelToWizardPage( ExportExcelToWizardPage.class.getName(), this );
+ addPage( toPage );
+ }
+
+
+ public boolean performFinish()
+ {
+
+ this.fromPage.saveDialogSettings();
+ this.toPage.saveDialogSettings();
+ boolean exportDn = this.fromPage.isExportDn();
+
+ ExportXlsJob eej = new ExportXlsJob( this.exportFilename, this.search.getConnection(), this.search
+ .getSearchParameter(), exportDn );
+ eej.execute();
+
+ return true;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportLdifFromWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportLdifFromWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportLdifFromWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportLdifFromWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.search.SearchPageWrapper;
+
+
+public class ExportLdifFromWizardPage extends ExportBaseFromWizardPage
+{
+
+ public ExportLdifFromWizardPage( String pageName, ExportBaseWizard wizard )
+ {
+ super( pageName, wizard, new SearchPageWrapper(
+ SearchPageWrapper.NAME_INVISIBLE
+ | SearchPageWrapper.ALLATTRIBUTES_VISIBLE
+ | SearchPageWrapper.OPERATIONALATTRIBUTES_VISIBLE
+ | ( ( wizard.getSearch().getReturningAttributes() == null || wizard.getSearch()
+ .getReturningAttributes().length == 0 ) ? SearchPageWrapper.ALLATTRIBUTES_CHECKED
+ : SearchPageWrapper.NONE ) ) );
+ super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+ BrowserUIConstants.IMG_EXPORT_LDIF_WIZARD ) );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportLdifToWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportLdifToWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportLdifToWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportLdifToWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.preferences.TextFormatsPreferencePage;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+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;
+
+
+public class ExportLdifToWizardPage extends ExportBaseToPage
+{
+
+ private static final String[] EXTENSIONS = new String[]
+ { "*.ldif", "*.*" };
+
+
+ public ExportLdifToWizardPage( String pageName, ExportBaseWizard wizard )
+ {
+ super( pageName, wizard );
+ super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+ BrowserUIConstants.IMG_EXPORT_LDIF_WIZARD ) );
+ }
+
+
+ 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 LDIF 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.LDIF_TAB ).open();
+ }
+ } );
+ }
+
+
+ protected String[] getExtensions()
+ {
+ return EXTENSIONS;
+ }
+
+
+ protected String getFileType()
+ {
+ return "LDIF";
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportLdifWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportLdifWizard.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportLdifWizard.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ExportLdifWizard.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.jobs.ExportLdifJob;
+
+
+public class ExportLdifWizard extends ExportBaseWizard
+{
+
+ private ExportLdifFromWizardPage fromPage;
+
+ private ExportLdifToWizardPage toPage;
+
+
+ public ExportLdifWizard()
+ {
+ super( "LDIF Export" );
+ }
+
+
+ public static String getId()
+ {
+ return ExportLdifWizard.class.getName();
+ }
+
+
+ public void addPages()
+ {
+ fromPage = new ExportLdifFromWizardPage( ExportLdifFromWizardPage.class.getName(), this );
+ addPage( fromPage );
+ toPage = new ExportLdifToWizardPage( ExportLdifToWizardPage.class.getName(), this );
+ addPage( toPage );
+ }
+
+
+ public boolean performFinish()
+ {
+
+ this.fromPage.saveDialogSettings();
+ this.toPage.saveDialogSettings();
+
+ ExportLdifJob elj = new ExportLdifJob( this.exportFilename, this.search.getConnection(), this.search
+ .getSearchParameter() );
+ elj.execute();
+
+ return true;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ImportLdifMainWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ImportLdifMainWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ImportLdifMainWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ImportLdifMainWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,309 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import java.io.File;
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.FileBrowserWidget;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyEvent;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyListener;
+import org.apache.directory.ldapstudio.browser.ui.widgets.search.ConnectionWidget;
+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;
+import org.eclipse.swt.widgets.Group;
+
+
+public class ImportLdifMainWizardPage extends WizardPage
+{
+
+ public static final String CONTINUE_ON_ERROR_DIALOGSETTING_KEY = ImportLdifMainWizardPage.class.getName()
+ + ".continueOnError";
+
+ private static final String[] EXTENSIONS = new String[]
+ { "*.ldif", "*.*" };
+
+ private ImportLdifWizard wizard;
+
+ // private Text ldifFilenameText;
+ private FileBrowserWidget ldifFileBrowserWidget;
+
+ private ConnectionWidget connectionWidget;
+
+ private Button enableLoggingButton;
+
+ private Button useDefaultLogfileButton;
+
+ private Button useCustomLogfileButton;
+
+ private String customLogfileName;
+
+ private FileBrowserWidget logFileBrowserWidget;
+
+ // private Text logfileText;
+ private Button overwriteLogfileButton;
+
+ private Button continueOnErrorButton;
+
+
+ public ImportLdifMainWizardPage( String pageName, ImportLdifWizard wizard )
+ {
+ super( pageName );
+ super.setTitle( "LDIF Import" );
+ super.setDescription( "Please select a connection and the LDIF to import" );
+ super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+ BrowserUIConstants.IMG_IMPORT_LDIF_WIZARD ) );
+ super.setPageComplete( false );
+
+ this.wizard = wizard;
+ }
+
+
+ public void dispose()
+ {
+ super.dispose();
+ }
+
+
+ public void setVisible( boolean visible )
+ {
+ super.setVisible( visible );
+ }
+
+
+ private void validate()
+ {
+
+ boolean ok = true;
+
+ File ldifFile = new File( ldifFileBrowserWidget.getFilename() );
+ if ( "".equals( ldifFileBrowserWidget.getFilename() ) )
+ {
+ setErrorMessage( null );
+ ok = false;
+ }
+ else if ( !ldifFile.isFile() || !ldifFile.exists() )
+ {
+ setErrorMessage( "Selected LDIF file doesn't exist." );
+ ok = false;
+ }
+ else if ( !ldifFile.canRead() )
+ {
+ setErrorMessage( "Selected LDIF file is not readable." );
+ ok = false;
+ }
+ else if ( this.enableLoggingButton.getSelection() )
+ {
+ File logFile = new File( logFileBrowserWidget.getFilename() );
+ File logFileDirectory = logFile.getParentFile();
+
+ if ( logFile.equals( ldifFile ) )
+ {
+ setErrorMessage( "LDIF file and Logfile must not be equal." );
+ ok = false;
+ }
+ else if ( logFile.isDirectory() )
+ {
+ setErrorMessage( "Selected logfile is no file." );
+ ok = false;
+ }
+ else if ( logFile.exists() && !this.overwriteLogfileButton.getSelection() )
+ {
+ setErrorMessage( "Selected logfile already exists. Select option 'Overwrite existing logfile' if you want to overwrite the logfile." );
+ ok = false;
+ }
+ else if ( logFile.exists() && !logFile.canWrite() )
+ {
+ setErrorMessage( "Selected logfile is not writeable." );
+ ok = false;
+ }
+ else if ( logFile.getParentFile() == null )
+ {
+ setErrorMessage( "Selected logfile directory is not writeable." );
+ ok = false;
+ }
+ else if ( !logFile.exists() && ( logFileDirectory == null || !logFileDirectory.canWrite() ) )
+ {
+ setErrorMessage( "Selected logfile directory is not writeable." );
+ ok = false;
+ }
+ }
+
+ if ( wizard.getImportConnection() == null )
+ {
+ ok = false;
+ }
+
+ if ( ok )
+ {
+ setErrorMessage( null );
+ }
+ setPageComplete( ok );
+ getContainer().updateButtons();
+ }
+
+
+ public void createControl( Composite parent )
+ {
+
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
+
+ // LDIF file
+ BaseWidgetUtils.createLabel( composite, "LDIF file:", 1 );
+ ldifFileBrowserWidget = new FileBrowserWidget( "Select LDIF File", EXTENSIONS, FileBrowserWidget.TYPE_OPEN );
+ ldifFileBrowserWidget.createWidget( composite );
+ ldifFileBrowserWidget.addWidgetModifyListener( new WidgetModifyListener()
+ {
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ wizard.setLdifFilename( ldifFileBrowserWidget.getFilename() );
+ if ( useDefaultLogfileButton.getSelection() )
+ {
+ logFileBrowserWidget.setFilename( ldifFileBrowserWidget.getFilename() + ".log" );
+ }
+ validate();
+ }
+ } );
+
+ // Connection
+ BaseWidgetUtils.createLabel( composite, "Import into:", 1 );
+ connectionWidget = new ConnectionWidget( wizard.getImportConnection() );
+ connectionWidget.createWidget( composite );
+ connectionWidget.addWidgetModifyListener( new WidgetModifyListener()
+ {
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ wizard.setImportConnection( connectionWidget.getConnection() );
+ validate();
+ }
+ } );
+
+ // Logging
+ Composite loggingOuterComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 3 );
+ Group loggingGroup = BaseWidgetUtils.createGroup( loggingOuterComposite, "Logging", 1 );
+ Composite loggingContainer = BaseWidgetUtils.createColumnContainer( loggingGroup, 3, 1 );
+
+ enableLoggingButton = BaseWidgetUtils.createCheckbox( loggingContainer, "Enable logging", 3 );
+ enableLoggingButton.setSelection( true );
+ wizard.setEnableLogging( enableLoggingButton.getSelection() );
+ enableLoggingButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent event )
+ {
+ wizard.setEnableLogging( enableLoggingButton.getSelection() );
+ useDefaultLogfileButton.setEnabled( enableLoggingButton.getSelection() );
+ useCustomLogfileButton.setEnabled( enableLoggingButton.getSelection() );
+ logFileBrowserWidget.setEnabled( enableLoggingButton.getSelection()
+ && useCustomLogfileButton.getSelection() );
+ overwriteLogfileButton.setEnabled( enableLoggingButton.getSelection() );
+ validate();
+ }
+ } );
+
+ BaseWidgetUtils.createRadioIndent( loggingContainer, 1 );
+ useDefaultLogfileButton = BaseWidgetUtils.createRadiobutton( loggingContainer, "Use default logfile", 2 );
+ useDefaultLogfileButton.setSelection( true );
+ useDefaultLogfileButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent event )
+ {
+ String temp = customLogfileName;
+ logFileBrowserWidget.setFilename( ldifFileBrowserWidget.getFilename() + ".log" );
+ logFileBrowserWidget.setEnabled( false );
+ customLogfileName = temp;
+ validate();
+ }
+ } );
+
+ BaseWidgetUtils.createRadioIndent( loggingContainer, 1 );
+ useCustomLogfileButton = BaseWidgetUtils.createRadiobutton( loggingContainer, "Use custom logfile", 2 );
+ useCustomLogfileButton.setSelection( false );
+ useCustomLogfileButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent event )
+ {
+ logFileBrowserWidget.setFilename( customLogfileName != null ? customLogfileName : "" );
+ logFileBrowserWidget.setEnabled( true );
+ validate();
+ }
+ } );
+
+ BaseWidgetUtils.createRadioIndent( loggingContainer, 1 );
+ logFileBrowserWidget = new FileBrowserWidget( "Select Logfile", null, FileBrowserWidget.TYPE_SAVE );
+ logFileBrowserWidget.createWidget( loggingContainer );
+ logFileBrowserWidget.addWidgetModifyListener( new WidgetModifyListener()
+ {
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ customLogfileName = logFileBrowserWidget.getFilename();
+ wizard.setLogFilename( customLogfileName );
+ validate();
+ }
+ } );
+ logFileBrowserWidget.setEnabled( false );
+
+ BaseWidgetUtils.createRadioIndent( loggingContainer, 1 );
+ overwriteLogfileButton = BaseWidgetUtils.createCheckbox( loggingContainer, "Overwrite existing logfile", 2 );
+ overwriteLogfileButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent event )
+ {
+ validate();
+ }
+ } );
+
+ // Continue
+ continueOnErrorButton = BaseWidgetUtils.createCheckbox( composite, "Continue on error", 3 );
+ if ( BrowserUIPlugin.getDefault().getDialogSettings().get( CONTINUE_ON_ERROR_DIALOGSETTING_KEY ) == null )
+ {
+ BrowserUIPlugin.getDefault().getDialogSettings().put( CONTINUE_ON_ERROR_DIALOGSETTING_KEY, false );
+ }
+ continueOnErrorButton.setSelection( BrowserUIPlugin.getDefault().getDialogSettings().getBoolean(
+ CONTINUE_ON_ERROR_DIALOGSETTING_KEY ) );
+ wizard.setContinueOnError( continueOnErrorButton.getSelection() );
+ continueOnErrorButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent event )
+ {
+ wizard.setContinueOnError( continueOnErrorButton.getSelection() );
+ validate();
+ }
+ } );
+
+ setControl( composite );
+ // nameText.setFocus();
+ }
+
+
+ public void saveDialogSettings()
+ {
+ this.ldifFileBrowserWidget.saveDialogSettings();
+ BrowserUIPlugin.getDefault().getDialogSettings().put( CONTINUE_ON_ERROR_DIALOGSETTING_KEY,
+ continueOnErrorButton.getSelection() );
+ }
+
+}
\ No newline at end of file
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ImportLdifWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ImportLdifWizard.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ImportLdifWizard.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/ImportLdifWizard.java Mon Dec 18 09:57:38 2006
@@ -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.ldapstudio.browser.ui.wizards;
+
+
+import java.io.File;
+
+import org.apache.directory.ldapstudio.browser.core.jobs.ImportLdifJob;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IBookmark;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+
+
+public class ImportLdifWizard extends Wizard implements IImportWizard
+{
+
+ private ImportLdifMainWizardPage mainPage;
+
+ private String ldifFilename;
+
+ private IConnection importConnection;
+
+ private boolean enableLogging;
+
+ private String logFilename;
+
+ private boolean continueOnError;
+
+
+ public ImportLdifWizard()
+ {
+ super();
+ super.setWindowTitle( "LDIF Import" );
+ }
+
+
+ public ImportLdifWizard( IConnection selectedConnection )
+ {
+ super.setWindowTitle( "LDIF Import" );
+ this.importConnection = selectedConnection;
+ }
+
+
+ public static String getId()
+ {
+ return ImportLdifWizard.class.getName();
+ }
+
+
+ public void init( IWorkbench workbench, IStructuredSelection selection )
+ {
+ Object o = selection.getFirstElement();
+ if ( o instanceof IEntry )
+ {
+ this.importConnection = ( ( IEntry ) o ).getConnection();
+ }
+ else if ( o instanceof ISearchResult )
+ {
+ this.importConnection = ( ( ISearchResult ) o ).getEntry().getConnection();
+ }
+ else if ( o instanceof IBookmark )
+ {
+ this.importConnection = ( ( IBookmark ) o ).getConnection();
+ }
+ else if ( o instanceof IAttribute )
+ {
+ this.importConnection = ( ( IAttribute ) o ).getEntry().getConnection();
+ }
+ else if ( o instanceof IValue )
+ {
+ this.importConnection = ( ( IValue ) o ).getAttribute().getEntry().getConnection();
+ }
+ else if ( o instanceof IConnection )
+ {
+ this.importConnection = ( IConnection ) o;
+ }
+ else
+ {
+ this.importConnection = null;
+ }
+ }
+
+
+ public void addPages()
+ {
+ mainPage = new ImportLdifMainWizardPage( ImportLdifMainWizardPage.class.getName(), this );
+ addPage( mainPage );
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( getContainer().getShell(),
+ BrowserUIPlugin.PLUGIN_ID + "." + "tools_ldifimport_wizard" );
+ }
+
+
+ public boolean performFinish()
+ {
+
+ this.mainPage.saveDialogSettings();
+
+ if ( this.ldifFilename != null && !"".equals( this.ldifFilename ) )
+ {
+ File ldifFile = new File( this.ldifFilename );
+
+ if ( this.enableLogging )
+ {
+ File logFile = new File( this.logFilename );
+ new ImportLdifJob( this.importConnection, ldifFile, logFile, this.continueOnError ).execute();
+ }
+ else
+ {
+ new ImportLdifJob( this.importConnection, ldifFile, this.continueOnError ).execute();
+ }
+
+ return true;
+ }
+ return false;
+ }
+
+
+ public IConnection getImportConnection()
+ {
+ return importConnection;
+ }
+
+
+ public void setImportConnection( IConnection importConnection )
+ {
+ this.importConnection = importConnection;
+ }
+
+
+ public void setLdifFilename( String ldifFilename )
+ {
+ this.ldifFilename = ldifFilename;
+ }
+
+
+ public void setContinueOnError( boolean continueOnError )
+ {
+ this.continueOnError = continueOnError;
+ }
+
+
+ public void setLogFilename( String logFilename )
+ {
+ this.logFilename = logFilename;
+ }
+
+
+ public void setEnableLogging( boolean b )
+ {
+ this.enableLogging = b;
+ }
+
+}