directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1399227 - in /directory/studio/trunk/plugins/ldapbrowser.ui: ./ src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/
Date Wed, 17 Oct 2012 13:23:10 GMT
Author: pamarcelot
Date: Wed Oct 17 13:23:09 2012
New Revision: 1399227

URL: http://svn.apache.org/viewvc?rev=1399227&view=rev
Log:
Fix for DIRSTUDIO-657 (Add options to output the resulting LDIF of a batch operation to a
file or to the clipboard)

Modified:
    directory/studio/trunk/plugins/ldapbrowser.ui/pom.xml
    directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationFinishWizardPage.java
    directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationWizard.java
    directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/messages.properties
    directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/messages_de.properties
    directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/messages_fr.properties

Modified: directory/studio/trunk/plugins/ldapbrowser.ui/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.ui/pom.xml?rev=1399227&r1=1399226&r2=1399227&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.ui/pom.xml (original)
+++ directory/studio/trunk/plugins/ldapbrowser.ui/pom.xml Wed Oct 17 13:23:09 2012
@@ -130,11 +130,13 @@
  org.apache.directory.studio.ldifparser,
  org.eclipse.core.expressions,
  org.eclipse.core.filesystem,
+ org.eclipse.core.resources,
  org.eclipse.core.runtime,
  org.eclipse.jface.text,
  org.eclipse.ui,
  org.eclipse.ui.editors,
  org.eclipse.ui.forms,
+ org.eclipse.ui.ide,
  org.eclipse.ui.views,
  org.eclipse.ui.workbench.texteditor,
  org.eclipse.search</Require-Bundle>
@@ -242,6 +244,11 @@
     </dependency>
     <dependency>
       <groupId>org.eclipse.core</groupId>
+      <artifactId>resources</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.core</groupId>
       <artifactId>jobs</artifactId>
       <scope>provided</scope>
     </dependency>

Modified: directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationFinishWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationFinishWizardPage.java?rev=1399227&r1=1399226&r2=1399227&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationFinishWizardPage.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationFinishWizardPage.java
Wed Oct 17 13:23:09 2012
@@ -27,6 +27,7 @@ import org.eclipse.jface.wizard.WizardPa
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 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;
@@ -41,17 +42,36 @@ import org.eclipse.swt.widgets.Composite
 public class BatchOperationFinishWizardPage extends WizardPage
 {
     /** The continue on error flag key */
+    public static final String EXECUTE_METHOD_DIALOGSETTING_KEY = BatchOperationFinishWizardPage.class.getName()
+        + ".executeMethod"; //$NON-NLS-1$
+
+    /** The continue on error flag key */
     public static final String CONTINUE_ON_ERROR_DIALOGSETTING_KEY = BatchOperationFinishWizardPage.class.getName()
         + ".continueOnError"; //$NON-NLS-1$
 
+    // Execution Method Values
     public final static int EXECUTION_METHOD_NONE = -1;
-    public final static int EXECUTION_METHOD_LDIF = 0;
-    public final static int EXECUTION_METHOD_ONLINE = 1;
+    public final static int EXECUTION_METHOD_ON_CONNECTION = 0;
+    public final static int EXECUTION_METHOD_LDIF_EDITOR = 1;
+    public final static int EXECUTION_METHOD_LDIF_FILE = 2;
+    public final static int EXECUTION_METHOD_LDIF_CLIPBOARD = 3;
 
     // UI widgets
-    private Button executeOnlineButton;
-    private Button generateLdifButton;
+    private Button executeOnConnectionButton;
     private Button continueOnErrorButton;
+    private Button generateLdifButton;
+    private Button generateInLDIFEditorButton;
+    private Button generateInFileButton;
+    private Button generateInClipboardButton;
+
+    // Listeners
+    private SelectionListener validateSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            validate();
+        }
+    };
 
 
     /**
@@ -69,63 +89,134 @@ public class BatchOperationFinishWizardP
 
 
     /**
-     * Validates the page.
-     */
-    private void validate()
-    {
-        continueOnErrorButton.setEnabled( getExecutionMethod() == EXECUTION_METHOD_ONLINE
);
-        setPageComplete( getExecutionMethod() != EXECUTION_METHOD_NONE );
-    }
-
-
-    /**
      * {@inheritDoc}
      */
     public void createControl( Composite parent )
     {
         // Composite
         Composite composite = new Composite( parent, SWT.NONE );
-        GridLayout gl = new GridLayout( 2, false );
+        GridLayout gl = new GridLayout();
         composite.setLayout( gl );
         composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
 
-        // Execute Online Button
-        executeOnlineButton = BaseWidgetUtils.createRadiobutton( composite, Messages
-            .getString( "BatchOperationFinishWizardPage.ExecuteOnline" ), 2 ); //$NON-NLS-1$
-        executeOnlineButton.setSelection( true );
-        executeOnlineButton.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent e )
-            {
-                validate();
-            }
-        } );
+        // Execute On Connection Button
+        executeOnConnectionButton = BaseWidgetUtils.createRadiobutton( composite, Messages
+            .getString( "BatchOperationFinishWizardPage.ExecuteOnConnection" ), 1 ); //$NON-NLS-1$
+
+        // Execute On Connection Composite
+        Composite executeOnConnectionComposite = BaseWidgetUtils.createColumnContainer( composite,
2, 1 );
 
         // Continue On Error Radio Button
-        BaseWidgetUtils.createRadioIndent( composite, 1 );
-        continueOnErrorButton = BaseWidgetUtils.createCheckbox( composite, Messages
+        BaseWidgetUtils.createRadioIndent( executeOnConnectionComposite, 1 );
+        continueOnErrorButton = BaseWidgetUtils.createCheckbox( executeOnConnectionComposite,
Messages
             .getString( "ImportLdifMainWizardPage.ContinueOnError" ), 1 ); //$NON-NLS-1$
-        if ( BrowserUIPlugin.getDefault().getDialogSettings().get( CONTINUE_ON_ERROR_DIALOGSETTING_KEY
) == null )
-        {
-            BrowserUIPlugin.getDefault().getDialogSettings().put( CONTINUE_ON_ERROR_DIALOGSETTING_KEY,
true );
-        }
-        continueOnErrorButton.setSelection( BrowserUIPlugin.getDefault().getDialogSettings()
-            .getBoolean( CONTINUE_ON_ERROR_DIALOGSETTING_KEY ) );
 
         // Generate LDIF Button
         generateLdifButton = BaseWidgetUtils.createRadiobutton( composite, Messages
-            .getString( "BatchOperationFinishWizardPage.GenerateLDIF" ), 2 ); //$NON-NLS-1$
-        generateLdifButton.addSelectionListener( new SelectionAdapter()
+            .getString( "BatchOperationFinishWizardPage.GenerateLDIF" ), 1 ); //$NON-NLS-1$
+
+        // Generate LDIF Button Composite
+        Composite generateLdifButtonComposite = BaseWidgetUtils.createColumnContainer( composite,
2, 1 );
+
+        // In The LDIF Editor Button
+        BaseWidgetUtils.createRadioIndent( generateLdifButtonComposite, 1 );
+        generateInLDIFEditorButton = BaseWidgetUtils.createRadiobutton( generateLdifButtonComposite,
Messages
+            .getString( "BatchOperationFinishWizardPage.GenerateLDIFInLDIFEditor" ), 1 );
//$NON-NLS-1$
+
+        // In A File Button
+        BaseWidgetUtils.createRadioIndent( generateLdifButtonComposite, 1 );
+        generateInFileButton = BaseWidgetUtils.createRadiobutton( generateLdifButtonComposite,
Messages
+            .getString( "BatchOperationFinishWizardPage.GenerateLDIFInFile" ), 1 ); //$NON-NLS-1$
+
+        // In The Clipboard Button
+        BaseWidgetUtils.createRadioIndent( generateLdifButtonComposite, 1 );
+        generateInClipboardButton = BaseWidgetUtils.createRadiobutton( generateLdifButtonComposite,
Messages
+            .getString( "BatchOperationFinishWizardPage.GenerateLDIFInClipBoard" ), 1 );
//$NON-NLS-1$
+
+        init();
+        validate();
+        addListeners();
+
+        setControl( composite );
+    }
+
+
+    /**
+     * Initializes the UI.
+     */
+    private void init()
+    {
+        try
         {
-            public void widgetSelected( SelectionEvent e )
+            // Default value for the 'Execute Method' dialog setting
+            if ( BrowserUIPlugin.getDefault().getDialogSettings().get( EXECUTE_METHOD_DIALOGSETTING_KEY
) == null )
             {
-                validate();
+                BrowserUIPlugin.getDefault().getDialogSettings()
+                    .put( EXECUTE_METHOD_DIALOGSETTING_KEY, EXECUTION_METHOD_ON_CONNECTION
);
             }
-        } );
 
-        validate();
+            // Default value for the 'Continue On Error' dialog setting
+            if ( BrowserUIPlugin.getDefault().getDialogSettings().get( CONTINUE_ON_ERROR_DIALOGSETTING_KEY
) == null )
+            {
+                BrowserUIPlugin.getDefault().getDialogSettings().put( CONTINUE_ON_ERROR_DIALOGSETTING_KEY,
true );
+            }
 
-        setControl( composite );
+            // Getting the 'Execute Method' dialog setting
+            int executeMethod = BrowserUIPlugin.getDefault().getDialogSettings()
+                .getInt( EXECUTE_METHOD_DIALOGSETTING_KEY );
+
+            switch ( executeMethod )
+            {
+                case EXECUTION_METHOD_ON_CONNECTION:
+                    executeOnConnectionButton.setSelection( true );
+                    generateInLDIFEditorButton.setSelection( true );
+                    break;
+                case EXECUTION_METHOD_LDIF_EDITOR:
+                    generateLdifButton.setSelection( true );
+                    generateInLDIFEditorButton.setSelection( true );
+                    break;
+                case EXECUTION_METHOD_LDIF_FILE:
+                    generateLdifButton.setSelection( true );
+                    generateInFileButton.setSelection( true );
+                    break;
+                case EXECUTION_METHOD_LDIF_CLIPBOARD:
+                    generateLdifButton.setSelection( true );
+                    generateInClipboardButton.setSelection( true );
+                    break;
+            }
+
+            // Getting the 'Continue On Error' dialog setting
+            continueOnErrorButton.setSelection( BrowserUIPlugin.getDefault().getDialogSettings()
+                .getBoolean( CONTINUE_ON_ERROR_DIALOGSETTING_KEY ) );
+        }
+        catch ( Exception e )
+        {
+            // Nothing to do
+        }
+    }
+
+
+    /**
+     * Validates the page.
+     */
+    private void validate()
+    {
+        continueOnErrorButton.setEnabled( executeOnConnectionButton.getSelection() );
+        generateInLDIFEditorButton.setEnabled( generateLdifButton.getSelection() );
+        generateInFileButton.setEnabled( generateLdifButton.getSelection() );
+        generateInClipboardButton.setEnabled( generateLdifButton.getSelection() );
+
+        setPageComplete( getExecutionMethod() != EXECUTION_METHOD_NONE );
+    }
+
+
+    /**
+     * Adds listeners.
+     */
+    private void addListeners()
+    {
+        executeOnConnectionButton.addSelectionListener( validateSelectionListener );
+        generateLdifButton.addSelectionListener( validateSelectionListener );
     }
 
 
@@ -136,18 +227,27 @@ public class BatchOperationFinishWizardP
      */
     public int getExecutionMethod()
     {
-        if ( executeOnlineButton.getSelection() )
+        if ( executeOnConnectionButton.getSelection() )
         {
-            return EXECUTION_METHOD_ONLINE;
+            return EXECUTION_METHOD_ON_CONNECTION;
         }
         else if ( generateLdifButton.getSelection() )
         {
-            return EXECUTION_METHOD_LDIF;
-        }
-        else
-        {
-            return EXECUTION_METHOD_NONE;
+            if ( generateInLDIFEditorButton.getSelection() )
+            {
+                return EXECUTION_METHOD_LDIF_EDITOR;
+            }
+            else if ( generateInFileButton.getSelection() )
+            {
+                return EXECUTION_METHOD_LDIF_FILE;
+            }
+            else if ( generateInClipboardButton.getSelection() )
+            {
+                return EXECUTION_METHOD_LDIF_CLIPBOARD;
+            }
         }
+
+        return EXECUTION_METHOD_NONE;
     }
 
 
@@ -167,7 +267,8 @@ public class BatchOperationFinishWizardP
      */
     public void saveDialogSettings()
     {
-        BrowserUIPlugin.getDefault().getDialogSettings().put( CONTINUE_ON_ERROR_DIALOGSETTING_KEY,
-            continueOnErrorButton.getSelection() );
+        BrowserUIPlugin.getDefault().getDialogSettings().put( EXECUTE_METHOD_DIALOGSETTING_KEY,
getExecutionMethod() );
+        BrowserUIPlugin.getDefault().getDialogSettings()
+            .put( CONTINUE_ON_ERROR_DIALOGSETTING_KEY, getContinueOnError() );
     }
 }

Modified: directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationWizard.java?rev=1399227&r1=1399226&r2=1399227&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationWizard.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationWizard.java
Wed Oct 17 13:23:09 2012
@@ -21,10 +21,17 @@
 package org.apache.directory.studio.ldapbrowser.ui.wizards;
 
 
+import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileWriter;
+
 import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.studio.common.ui.CommonUIUtils;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.ui.RunnableContextRunner;
 import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils;
+import org.apache.directory.studio.ldapbrowser.common.actions.CopyAction;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
 import org.apache.directory.studio.ldapbrowser.core.jobs.ExecuteLdifRunnable;
 import org.apache.directory.studio.ldapbrowser.core.jobs.SearchRunnable;
@@ -39,44 +46,55 @@ import org.apache.directory.studio.ldapb
 import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
 import org.apache.directory.studio.ldifeditor.editor.LdifEditor;
 import org.apache.directory.studio.ldifeditor.editor.NonExistingLdifEditorInput;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
 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.osgi.util.NLS;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
 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.dialogs.SaveAsDialog;
 import org.eclipse.ui.texteditor.IDocumentProvider;
 
 
 public class BatchOperationWizard extends Wizard implements INewWizard
 {
-
+    /** The connection */
     private IBrowserConnection connection;
 
+    // Wizard pages
     private BatchOperationApplyOnWizardPage applyOnPage;
-
     private BatchOperationTypeWizardPage typePage;
-
     private BatchOperationLdifWizardPage ldifPage;
-
     private BatchOperationModifyWizardPage modifyPage;
-
     private BatchOperationFinishWizardPage finishPage;
 
 
+    /**
+     * Creates a new instance of BatchOperationWizard.
+     */
     public BatchOperationWizard()
     {
         super.setWindowTitle( Messages.getString( "BatchOperationWizard.BatchOperation" )
); //$NON-NLS-1$
@@ -84,18 +102,29 @@ public class BatchOperationWizard extend
     }
 
 
+    /**
+     * Gets the id.
+     *
+     * @return the id
+     */
     public static String getId()
     {
         return BrowserUIConstants.WIZARD_BATCH_OPERATION;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void init( IWorkbench workbench, IStructuredSelection selection )
     {
         // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection()
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void addPages()
     {
 
@@ -164,19 +193,29 @@ public class BatchOperationWizard extend
             BrowserUIConstants.PLUGIN_ID + "." + "tools_batchoperation_wizard" ); //$NON-NLS-1$
//$NON-NLS-2$
     }
 
+    /**
+     * This private class implements a dummy wizard page that is displayed when no connection
is selected.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     */
     class DummyWizardPage extends WizardPage
     {
-
+        /**
+         * Creates a new instance of DummyWizardPage.
+         */
         protected DummyWizardPage()
         {
             super( "" ); //$NON-NLS-1$
             super.setTitle( Messages.getString( "BatchOperationWizard.NoConnectionSelected"
) ); //$NON-NLS-1$
-            super.setDescription( Messages.getString( "BatchOperationWizard.SelectOPenCollection"
) ); //$NON-NLS-1$
+            super.setDescription( Messages.getString( "BatchOperationWizard.SelectOpenConnection"
) ); //$NON-NLS-1$
             // super.setImageDescriptor(BrowserUIPlugin.getDefault().getImageDescriptor(BrowserUIConstants.IMG_ENTRY_WIZARD));
             super.setPageComplete( true );
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
         public void createControl( Composite parent )
         {
             Composite composite = new Composite( parent, SWT.NONE );
@@ -189,9 +228,11 @@ public class BatchOperationWizard extend
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public IWizardPage getNextPage( IWizardPage page )
     {
-
         if ( this.applyOnPage != null )
         {
 
@@ -230,9 +271,11 @@ public class BatchOperationWizard extend
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean canFinish()
     {
-
         if ( this.applyOnPage != null )
         {
             if ( !this.applyOnPage.isPageComplete() )
@@ -265,12 +308,18 @@ public class BatchOperationWizard extend
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean performCancel()
     {
         return true;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean performFinish()
     {
         if ( this.applyOnPage != null )
@@ -331,19 +380,16 @@ public class BatchOperationWizard extend
                     ldif.append( BrowserCoreConstants.LINE_SEPARATOR );
                 }
 
-                if ( finishPage.getExecutionMethod() == BatchOperationFinishWizardPage.EXECUTION_METHOD_LDIF
)
+                if ( finishPage.getExecutionMethod() == BatchOperationFinishWizardPage.EXECUTION_METHOD_LDIF_EDITOR
)
                 {
-
-                    IEditorInput input = new NonExistingLdifEditorInput();
-                    String editorId = LdifEditor.getId();
-
+                    // Opening an LDIF Editor with the LDIF content
                     try
                     {
-                        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-                        IWorkbenchPage page = window.getActivePage();
-                        IEditorPart editor = page.openEditor( input, editorId );
+                        IEditorInput input = new NonExistingLdifEditorInput();
+                        IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+                            .openEditor( input, LdifEditor.getId() );
                         IDocumentProvider documentProvider = ( ( LdifEditor ) editor ).getDocumentProvider();
-                        if ( documentProvider != null && input != null )
+                        if ( documentProvider != null )
                         {
                             IDocument document = documentProvider.getDocument( input );
                             if ( document != null )
@@ -359,8 +405,121 @@ public class BatchOperationWizard extend
 
                     return true;
                 }
-                else if ( finishPage.getExecutionMethod() == BatchOperationFinishWizardPage.EXECUTION_METHOD_ONLINE
)
+                else if ( finishPage.getExecutionMethod() == BatchOperationFinishWizardPage.EXECUTION_METHOD_LDIF_FILE
) // TODO
                 {
+                    // Saving the LDIF to a file
+
+                    // Getting the shell
+                    Shell shell = Display.getDefault().getActiveShell();
+
+                    // detect IDE or RCP:
+                    // check if perspective org.eclipse.ui.resourcePerspective is available
+                    boolean isIDE = CommonUIUtils.isIDEEnvironment();
+
+                    if ( isIDE )
+                    {
+                        // Asking the user for the location where to 'save as' the file
+                        SaveAsDialog dialog = new SaveAsDialog( shell );
+
+                        if ( dialog.open() != Dialog.OK )
+                        {
+                            return false;
+                        }
+
+                        // Getting if the resulting file
+                        IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile( dialog.getResult()
);
+
+                        try
+                        {
+                            // Creating the file if it does not exist
+                            if ( !file.exists() )
+                            {
+                                file.create( new ByteArrayInputStream( "".getBytes() ), true,
null ); //$NON-NLS-1$
+                            }
+
+                            // Saving the LDIF to the file in the workspace
+                            file.setContents( new ByteArrayInputStream( ldif.toString().getBytes()
), true, true,
+                                new NullProgressMonitor() );
+                        }
+                        catch ( Exception e )
+                        {
+                            return false;
+                        }
+                    }
+                    else
+                    {
+                        boolean canOverwrite = false;
+                        String path = null;
+
+                        while ( !canOverwrite )
+                        {
+                            // Open FileDialog
+                            FileDialog dialog = new FileDialog( shell, SWT.SAVE );
+                            path = dialog.open();
+                            if ( path == null )
+                            {
+                                return false;
+                            }
+
+                            // Check whether file exists and if so, confirm overwrite
+                            final File externalFile = new File( path );
+                            if ( externalFile.exists() )
+                            {
+                                String question = NLS.bind( Messages
+                                    .getString( "BatchOperationWizard.TheFileAlreadyExistsReplace"
), path ); //$NON-NLS-1$
+                                MessageDialog overwriteDialog = new MessageDialog( shell,
Messages
+                                    .getString( "BatchOperationWizard.Question" ), null,
question, //$NON-NLS-1$
+                                    MessageDialog.QUESTION, new String[]
+                                        {
+                                            IDialogConstants.YES_LABEL,
+                                            IDialogConstants.NO_LABEL,
+                                            IDialogConstants.CANCEL_LABEL }, 0 );
+                                int overwrite = overwriteDialog.open();
+                                switch ( overwrite )
+                                {
+                                    case 0: // Yes
+                                        canOverwrite = true;
+                                        break;
+                                    case 1: // No
+                                        break;
+                                    case 2: // Cancel
+                                    default:
+                                        return false;
+                                }
+                            }
+                            else
+                            {
+                                canOverwrite = true;
+                            }
+                        }
+
+                        // Saving the LDIF to the file on disk
+                        try
+                        {
+                            BufferedWriter outFile = new BufferedWriter( new FileWriter(
path ) );
+                            outFile.write( ldif.toString() );
+                            outFile.close();
+                        }
+                        catch ( Exception e )
+                        {
+                            return false;
+                        }
+                    }
+
+                    return true;
+                }
+                else if ( finishPage.getExecutionMethod() == BatchOperationFinishWizardPage.EXECUTION_METHOD_LDIF_CLIPBOARD
)
+                {
+                    // Copying the LDIF to the clipboard
+                    CopyAction.copyToClipboard( new Object[]
+                        { ldif.toString() }, new Transfer[]
+                        { TextTransfer.getInstance() } );
+
+                    return true;
+                }
+                else if ( finishPage.getExecutionMethod() == BatchOperationFinishWizardPage.EXECUTION_METHOD_ON_CONNECTION
)
+                {
+                    // Executing the LDIF on the connection
                     ExecuteLdifRunnable runnable = new ExecuteLdifRunnable( getConnection(),
ldif.toString(), true,
                         finishPage.getContinueOnError() );
                     StudioBrowserJob job = new StudioBrowserJob( runnable );
@@ -377,12 +536,22 @@ public class BatchOperationWizard extend
     }
 
 
+    /**
+     * Gets the type of the page.
+     *
+     * @return the type of the page
+     */
     public BatchOperationTypeWizardPage getTypePage()
     {
         return typePage;
     }
 
 
+    /**
+     * Gets the connection.
+     *
+     * @return the connection
+     */
     public IBrowserConnection getConnection()
     {
         return this.connection;

Modified: directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/messages.properties?rev=1399227&r1=1399226&r2=1399227&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/messages.properties
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/messages.properties
Wed Oct 17 13:23:09 2012
@@ -22,8 +22,11 @@ BatchOperationApplyOnWizardPage.ResultsO
 BatchOperationApplyOnWizardPage.SearchResultOf=Search Results of "{0}" ({1} Entries)
 BatchOperationApplyOnWizardPage.SelectApplicationEntries=Select Application Entries
 BatchOperationApplyOnWizardPage.SelectedEntries=Selected Entries ({0}) Entries
-BatchOperationFinishWizardPage.ExecuteOnline=Execute online
-BatchOperationFinishWizardPage.GenerateLDIF=Generate LDIF
+BatchOperationFinishWizardPage.ExecuteOnConnection=Execute on the connection
+BatchOperationFinishWizardPage.GenerateLDIF=Generate in LDIF format
+BatchOperationFinishWizardPage.GenerateLDIFInLDIFEditor=In the LDIF Editor
+BatchOperationFinishWizardPage.GenerateLDIFInFile=In a file
+BatchOperationFinishWizardPage.GenerateLDIFInClipBoard=In the clipboard
 BatchOperationFinishWizardPage.PleaseSelectBatchOperation=Please select if the batch operation
should be executed online or a LDIF should be generated.
 BatchOperationFinishWizardPage.SelectExecutionMethod=Select Execution Method
 BatchOperationLdifWizardPage.LDIFFragment=LDIF Fragment
@@ -37,7 +40,9 @@ BatchOperationTypeWizardPage.PleaseSelec
 BatchOperationTypeWizardPage.SelectOperationType=Select Operation Type
 BatchOperationWizard.BatchOperation=Batch Operation
 BatchOperationWizard.NoConnectionSelected=No connection selected or connection is closed
-BatchOperationWizard.SelectOPenCollection=In order to use the batch operation wizard please
select a opened connection.
+BatchOperationWizard.SelectOpenConnection=In order to use the batch operation wizard please
select an opened connection.
+BatchOperationWizard.TheFileAlreadyExistsReplace=The file "{0}" already exists. Do you want
to replace the existing file?
+BatchOperationWizard.Question=Question
 ExportBaseFromWizardPage.DataToExport=Data to Export
 ExportBaseFromWizardPage.PleaseDefineSearchParameters=Please define search parameters for
the export.
 ExportBaseToPage.ErrorDirectoryNotWritable=Selected {0} file directory is not writable.

Modified: directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/messages_de.properties?rev=1399227&r1=1399226&r2=1399227&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/messages_de.properties
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/messages_de.properties
Wed Oct 17 13:23:09 2012
@@ -22,8 +22,11 @@ BatchOperationApplyOnWizardPage.ResultsO
 BatchOperationApplyOnWizardPage.SearchResultOf=Suchresultate von "{0}" ({1} Eintr\u00E4ge)
 BatchOperationApplyOnWizardPage.SelectApplicationEntries=W\u00E4hle Applikations-Eintr\u00E4ge
 BatchOperationApplyOnWizardPage.SelectedEntries=Ausgew\u00E4hlte Eintr\u00E4ge ({0} Eintr\u00E4ge)
-BatchOperationFinishWizardPage.ExecuteOnline=Online ausf\u00FChren
-BatchOperationFinishWizardPage.GenerateLDIF=LDIF erstellen
+BatchOperationFinishWizardPage.ExecuteOnConnection=Ausf\u00FChren auf der Verbindung
+BatchOperationFinishWizardPage.GenerateLDIF=Generieren Sie im LDIF-Format
+BatchOperationFinishWizardPage.GenerateLDIFInLDIFEditor=In der LDIF Editor
+BatchOperationFinishWizardPage.GenerateLDIFInFile=In einer Datei
+BatchOperationFinishWizardPage.GenerateLDIFInClipBoard=In die Zwischenablage
 BatchOperationFinishWizardPage.PleaseSelectBatchOperation=Bitte w\u00E4hle ob der Batch Betrieb
online ausgef\u00FChrt werden soll oder ob ein LDIF erstellt werden soll.
 BatchOperationFinishWizardPage.SelectExecutionMethod=Ausf\u00FChr-Methode ausw\u00E4hlen
 BatchOperationLdifWizardPage.LDIFFragment=LDIF Fragment
@@ -37,7 +40,9 @@ BatchOperationTypeWizardPage.PleaseSelec
 BatchOperationTypeWizardPage.SelectOperationType=W\u00E4hle Betriebs-Typ
 BatchOperationWizard.BatchOperation=Batch-Betrieb
 BatchOperationWizard.NoConnectionSelected=Keine Verbindung ausgew\u00E4hlt oder Verbindung
geschlossen
-BatchOperationWizard.SelectOPenCollection=Um den Batch Betriebs-Assistenten zu verwenden
bitte eine offene Verbindung ausw\u00E4hlen.
+BatchOperationWizard.SelectOpenConnection=Um den Batch Betriebs-Assistenten zu verwenden
bitte eine offene Verbindung ausw\u00E4hlen.
+BatchOperationWizard.TheFileAlreadyExistsReplace=Die Datei "{0}" existiert bereits. Soll
die Datei \u00FCberschrieben werden?
+BatchOperationWizard.Question=Frage
 ExportBaseFromWizardPage.DataToExport=Zu exportierende Daten
 ExportBaseFromWizardPage.PleaseDefineSearchParameters=Bitte Such-Parameter f\u00FCr den Export
definieren.
 ExportBaseToPage.ErrorDirectoryNotWritable=Verzeichnis der ausgew\u00E4hlten Datei {0} ist
nicht beschreibbar.

Modified: directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/messages_fr.properties?rev=1399227&r1=1399226&r2=1399227&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/messages_fr.properties
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/messages_fr.properties
Wed Oct 17 13:23:09 2012
@@ -23,8 +23,11 @@ BatchOperationApplyOnWizardPage.SearchRe
 BatchOperationApplyOnWizardPage.SelectApplicationEntries=S\u00E9lectionner les entr\u00E9es
 BatchOperationApplyOnWizardPage.SelectedEntries=Entr\u00E9es s\u00E9lectionn\u00E9es ({0})
Entr\u00E9es
 
-BatchOperationFinishWizardPage.ExecuteOnline=Executer en mode connect\u00E9 
-BatchOperationFinishWizardPage.GenerateLDIF=Generere le fichier LDIF
+BatchOperationFinishWizardPage.ExecuteOnConnection=Executer sur la connexion
+BatchOperationFinishWizardPage.GenerateLDIF=G\u00E9n\u00E9rer au format LDIF
+BatchOperationFinishWizardPage.GenerateLDIFInLDIFEditor=Dans l'\u00E9diteur LDIF
+BatchOperationFinishWizardPage.GenerateLDIFInFile=Dans un fichier
+BatchOperationFinishWizardPage.GenerateLDIFInClipBoard=Dans le presse-papier
 BatchOperationFinishWizardPage.PleaseSelectBatchOperation=Veuillez indiquer si le groupe
d'op\u00E9rations doit \u00EAtre ex\u00E9cut\u00E9e imm\u00E9diatement ou si un fichier LDIF
doit \u00EAtre g\u00E9n\u00E9r\u00E9
 BatchOperationFinishWizardPage.SelectExecutionMethod=Choisir le mode d'ex\u00E9cution
 
@@ -42,7 +45,9 @@ BatchOperationTypeWizardPage.SelectOpera
 
 BatchOperationWizard.BatchOperation=Groupe d'op\u00E9rations
 BatchOperationWizard.NoConnectionSelected=Pas de connexion s\u00E9lectionn\u00E9e ou connexion
close
-BatchOperationWizard.SelectOPenCollection=Pour d\u00E9finir un groupe d'op\u00E9rations,
veuillez s\u00E9lectionner une connexion ouverte.
+BatchOperationWizard.SelectOpenConnection=Pour d\u00E9finir un groupe d'op\u00E9rations,
veuillez s\u00E9lectionner une connexion ouverte.
+BatchOperationWizard.TheFileAlreadyExistsReplace=The file "{0}" already exists. Do you want
to replace the existing file?
+BatchOperationWizard.Question=Question
 
 ExportBaseFromWizardPage.DataToExport=Donn\u00E9es \u00E0 exporter
 ExportBaseFromWizardPage.PleaseDefineSearchParameters=Veuillez d\u00E9finir les param\u00E8tres
de recherche pour l'exportation.



Mime
View raw message