directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r607060 - in /directory/sandbox/felixk: studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ s...
Date Thu, 27 Dec 2007 12:43:16 GMT
Author: felixk
Date: Thu Dec 27 04:43:15 2007
New Revision: 607060

URL: http://svn.apache.org/viewvc?rev=607060&view=rev
Log:
Updates from trunks

Added:
    directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/PluginUtils.java
  (with props)
    directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/NonExistingServerConfigurationInput.java
  (with props)
Modified:
    directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationEditor.java
    directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerConfigurationWriter.java
    directory/sandbox/felixk/studio-ldapbrowser-core/src/main/resources/org/apache/directory/studio/ldapbrowser/core/browsercoremessages.properties

Added: directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/PluginUtils.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/PluginUtils.java?rev=607060&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/PluginUtils.java
(added)
+++ directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/PluginUtils.java
Thu Dec 27 04:43:15 2007
@@ -0,0 +1,65 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.configuration;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+
+public class PluginUtils
+{
+    /**
+     * Checks, if this plugins runs in the Eclipse IDE or in RCP environment.
+     * This is done by looking for the Resource perspective extensions.
+     *
+     * @return true if this plugin runs in IDE environment
+     */
+    public static boolean isIDEEnvironment()
+    {
+        IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(
+            "org.eclipse.ui.perspectives" );
+        if ( extensionPoint != null )
+        {
+            IExtension[] extensions = extensionPoint.getExtensions();
+            if ( extensions != null )
+            {
+                for ( int i = 0; i < extensions.length; i++ )
+                {
+                    IExtension extension = extensions[i];
+                    IConfigurationElement[] elements = extension.getConfigurationElements();
+                    for ( int j = 0; j < elements.length; j++ )
+                    {
+                        IConfigurationElement element = elements[j];
+                        if ( element.getName().equals( "perspective" ) )
+                        {
+                            if ( "org.eclipse.ui.resourcePerspective".equals( element.getAttribute(
"id" ) ) )
+                            {
+                                return true;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+}

Propchange: directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/PluginUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/NonExistingServerConfigurationInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/NonExistingServerConfigurationInput.java?rev=607060&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/NonExistingServerConfigurationInput.java
(added)
+++ directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/NonExistingServerConfigurationInput.java
Thu Dec 27 04:43:15 2007
@@ -0,0 +1,146 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.configuration.editor;
+
+
+import org.apache.directory.studio.apacheds.configuration.model.ServerConfiguration;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+
+/**
+ * This class represents the Non Existing Server Configuration Input.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NonExistingServerConfigurationInput implements IEditorInput
+{
+    /** The Server Configuration */
+    private ServerConfiguration serverConfiguration;
+
+
+    /**
+     * Creates a new instance of NonExistingServerConfigurationInput.
+     *
+     * @param serverConfiguration
+     *      the Server Configuration
+     */
+    public NonExistingServerConfigurationInput( ServerConfiguration serverConfiguration )
+    {
+        this.serverConfiguration = serverConfiguration;
+    }
+
+
+    /**
+     * Gets the Server Configuration
+     *
+     * @return
+     *      the Server Configuration
+     */
+    public ServerConfiguration getServerConfiguration()
+    {
+        return serverConfiguration;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getToolTipText()
+     */
+    public String getToolTipText()
+    {
+        return "New Apache DS Configuration File";
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getName()
+     */
+    public String getName()
+    {
+        return "Apache DS Configuration";
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#exists()
+     */
+    public boolean exists()
+    {
+        return ( serverConfiguration != null );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getPersistable()
+     */
+    public IPersistableElement getPersistable()
+    {
+        return null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+     */
+    @SuppressWarnings("unchecked")
+    public Object getAdapter( Class adapter )
+    {
+        return null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals( Object obj )
+    {
+        if ( obj == null )
+        {
+            return false;
+        }
+
+        if ( obj instanceof NonExistingServerConfigurationInput )
+        {
+            NonExistingServerConfigurationInput input = ( NonExistingServerConfigurationInput
) obj;
+            if ( input.exists() && exists() )
+            {
+                ServerConfiguration inputServerConfiguration = input.getServerConfiguration();
+
+                if ( ( inputServerConfiguration != null ) && ( serverConfiguration
!= null ) )
+                {
+                    return inputServerConfiguration.equals( serverConfiguration );
+                }
+            }
+        }
+
+        return false;
+    }
+}

Propchange: directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/NonExistingServerConfigurationInput.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationEditor.java?rev=607060&r1=607059&r2=607060&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationEditor.java
(original)
+++ directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationEditor.java
Thu Dec 27 04:43:15 2007
@@ -25,18 +25,36 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileWriter;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 
 import org.apache.directory.studio.apacheds.configuration.Activator;
+import org.apache.directory.studio.apacheds.configuration.PluginUtils;
 import org.apache.directory.studio.apacheds.configuration.model.ServerConfiguration;
 import org.apache.directory.studio.apacheds.configuration.model.ServerConfigurationParser;
 import org.apache.directory.studio.apacheds.configuration.model.ServerConfigurationWriter;
+import org.apache.directory.studio.apacheds.configuration.model.ServerConfigurationWriterException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IPathEditorInput;
+import org.eclipse.ui.IPersistableElement;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.dialogs.SaveAsDialog;
@@ -83,10 +101,14 @@
             // The 'FileEditorInput' class is used when the file is opened
             // from a project in the workspace.
             {
-                FileEditorInput fei = ( FileEditorInput ) input;
-
                 ServerConfigurationParser parser = new ServerConfigurationParser();
-                serverConfiguration = parser.parse( fei.getFile().getContents() );
+                serverConfiguration = parser.parse( ( ( FileEditorInput ) input ).getFile().getContents()
);
+            }
+            else if ( input instanceof IPathEditorInput )
+            {
+                ServerConfigurationParser parser = new ServerConfigurationParser();
+                serverConfiguration = parser.parse( new FileInputStream( new File( ( ( IPathEditorInput
) input )
+                    .getPath().toOSString() ) ) );
             }
             else if ( inputClassName.equals( "org.eclipse.ui.internal.editors.text.JavaFileEditorInput"
)
                 || inputClassName.equals( "org.eclipse.ui.ide.FileStoreEditorInput" ) )
@@ -99,43 +121,13 @@
                 ServerConfigurationParser parser = new ServerConfigurationParser();
                 serverConfiguration = parser.parse( new FileInputStream( new File( input.getToolTipText()
) ) );
             }
-            else if ( input instanceof ServerConfigurationEditorInput )
+            else if ( input instanceof NonExistingServerConfigurationInput )
             {
                 // The 'ServerConfigurationEditorInput' class is used when a
                 // new Server Configuration File is created.
-                serverConfiguration = ( ( ServerConfigurationEditorInput ) input ).getServerConfiguration();
+                serverConfiguration = ( ( NonExistingServerConfigurationInput ) input ).getServerConfiguration();
                 dirty = true;
             }
-
-            // TODO What to do in the other cases ?
-
-            //        else
-            //        {
-            //            try
-            //            {
-            //                ServerConfigurationParser parser = new ServerConfigurationParser();
-            //                serverConfiguration = parser.parse( new FileInputStream( new
File( input.getToolTipText() ) ) );
-            //                serverConfiguration.setPath( input.getToolTipText() );
-            //            }
-            //            catch ( ServerConfigurationParserException e )
-            //            {
-            //                MessageBox messageBox = new MessageBox(
-            //                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
SWT.OK | SWT.ICON_ERROR );
-            //                messageBox.setText( "Error!" );
-            //                messageBox.setMessage( "An error occurred when reading the
file." + "\n" + e.getMessage() );
-            //                messageBox.open();
-            //                return;
-            //            }
-            //            catch ( FileNotFoundException e )
-            //            {
-            //                MessageBox messageBox = new MessageBox(
-            //                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
SWT.OK | SWT.ICON_ERROR );
-            //                messageBox.setText( "Error!" );
-            //                messageBox.setMessage( "An error occurred when reading the
file." + "\n" + e.getMessage() );
-            //                messageBox.open();
-            //                return;
-            //            }
-            //        }
         }
         catch ( Exception e )
         {
@@ -181,29 +173,29 @@
      */
     public void doSave( IProgressMonitor monitor )
     {
-        // Saving the Server Configuration
         monitor.beginTask( "Saving the Server Configuration", 5 );
-        generalPage.save();
-        monitor.worked( 1 );
-        partitionsPage.save();
-        monitor.worked( 1 );
-        interceptorsPage.save();
-        monitor.worked( 1 );
-        extendedOperationsPage.save();
-        monitor.worked( 1 );
+
+        // Saving the editor pages
+        saveEditorPages( monitor );
 
         try
         {
             IEditorInput input = getEditorInput();
             String inputClassName = input.getClass().getName();
+            boolean success = false;
             if ( input instanceof FileEditorInput )
             // FileEditorInput class is used when the file is opened
-            // from an project in the workspace.
+            // from a project in the workspace.
             {
                 // Saving the ServerConfiguration to disk
-                FileEditorInput fei = ( FileEditorInput ) input;
-                String xml = ServerConfigurationWriter.toXml( serverConfiguration );
-                fei.getFile().setContents( new ByteArrayInputStream( xml.getBytes() ), true,
true, monitor );
+                saveConfiguration( ( FileEditorInput ) input, monitor );
+                success = true;
+            }
+            else if ( input instanceof IPathEditorInput )
+            {
+                // Saving the ServerConfiguration to disk
+                saveConfiguration( ( ( IPathEditorInput ) input ).getPath().toOSString()
);
+                success = true;
             }
             else if ( inputClassName.equals( "org.eclipse.ui.internal.editors.text.JavaFileEditorInput"
)
                 || inputClassName.equals( "org.eclipse.ui.ide.FileStoreEditorInput" ) )
@@ -213,50 +205,20 @@
             // opening a file from the menu File > Open... in Eclipse 3.3.x
             {
                 // Saving the ServerConfiguration to disk
-                BufferedWriter outFile = new BufferedWriter( new FileWriter( input.getToolTipText()
) );
-                String xml = ServerConfigurationWriter.toXml( serverConfiguration );
-                outFile.write( xml );
-                outFile.close();
+                saveConfiguration( input.getToolTipText() );
+                success = true;
             }
-            else if ( input instanceof ServerConfigurationEditorInput )
+            else if ( input instanceof NonExistingServerConfigurationInput )
             {
                 // The 'ServerConfigurationEditorInput' class is used when a
                 // new Server Configuration File is created.
-                ServerConfigurationEditorInput serverConfigurationEditorInput = ( ServerConfigurationEditorInput
) input;
-
-                // Checking if the ServerConfiguration has already been saved
-                if ( serverConfigurationEditorInput.getPath() == null )
-                {
-                    FileDialog fd = new FileDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
-                        SWT.SAVE );
-                    fd.setText( "Select a file" );
-                    fd.setFilterExtensions( new String[]
-                        { "*.xml", "*.*" } );
-                    fd.setFilterNames( new String[]
-                        { "XML files", "All files" } );
-                    String selectedFile = fd.open();
-                    // selected == null if 'cancel' has been pushed
-                    if ( selectedFile == null || "".equals( selectedFile ) )
-                    {
-                        monitor.setCanceled( true );
-                        return;
-                    }
-
-                    // TODO Add the overwrite code...
 
-                    serverConfigurationEditorInput.setPath( selectedFile );
-                    setTitleToolTip( getEditorInput().getToolTipText() );
-                }
-
-                // Saving the ServerConfiguration to disk
-                BufferedWriter outFile = new BufferedWriter( new FileWriter( serverConfigurationEditorInput.getPath()
) );
-                String xml = ServerConfigurationWriter.toXml( serverConfiguration );
-                outFile.write( xml );
-                outFile.close();
+                // We are saving this as if it is a "Save as..." action.
+                success = doSaveAs( monitor );
             }
 
             monitor.worked( 1 );
-            setDirty( false );
+            setDirty( !success );
             monitor.done();
         }
         catch ( Exception e )
@@ -273,15 +235,225 @@
     }
 
 
+    /**
+     * Saves the editor pages.
+     *
+     * @param monitor
+     *      the monitor to use
+     */
+    private void saveEditorPages( IProgressMonitor monitor )
+    {
+        generalPage.save();
+        if ( monitor != null )
+        {
+            monitor.worked( 1 );
+        }
+
+        partitionsPage.save();
+        if ( monitor != null )
+        {
+            monitor.worked( 1 );
+        }
+
+        interceptorsPage.save();
+        if ( monitor != null )
+        {
+            monitor.worked( 1 );
+        }
+
+        extendedOperationsPage.save();
+        if ( monitor != null )
+        {
+            monitor.worked( 1 );
+        }
+    }
+
+
+    /**
+     * Saves the server configuration to the given path.
+     *
+     * @param path
+     *      the path where to save the file
+     * @throws IOException
+     * @throws ServerConfigurationWriterException
+     */
+    private void saveConfiguration( String path ) throws IOException, ServerConfigurationWriterException
+    {
+        BufferedWriter outFile = new BufferedWriter( new FileWriter( path ) );
+        String xml = ServerConfigurationWriter.toXml( serverConfiguration );
+        outFile.write( xml );
+        outFile.close();
+    }
+
+
+    /**
+     * Saves the server configuration using the given {@link FileEditorInput}.
+     *
+     * @param fei
+     *      the {@link FileEditorInput}
+     * @throws ServerConfigurationWriterException 
+     * @throws CoreException 
+     */
+    private void saveConfiguration( FileEditorInput fei, IProgressMonitor monitor )
+        throws ServerConfigurationWriterException, CoreException
+    {
+        String xml = ServerConfigurationWriter.toXml( serverConfiguration );
+        fei.getFile().setContents( new ByteArrayInputStream( xml.getBytes() ), true, true,
monitor );
+    }
+
+
     /* (non-Javadoc)
      * @see org.eclipse.ui.part.EditorPart#doSaveAs()
      */
     public void doSaveAs()
     {
-        SaveAsDialog dialog = new SaveAsDialog( Activator.getDefault().getWorkbench().getActiveWorkbenchWindow()
-            .getShell() );
-        dialog.setOriginalName( "Copy of" );
-        dialog.open();
+        try
+        {
+            getSite().getWorkbenchWindow().run( false, false, new IRunnableWithProgress()
+            {
+                public void run( IProgressMonitor monitor ) throws InvocationTargetException,
InterruptedException
+                {
+                    try
+                    {
+                        monitor.beginTask( "Saving the Server Configuration", 5 );
+                        saveEditorPages( monitor );
+                        boolean success = doSaveAs( monitor );
+                        monitor.worked( 1 );
+                        setDirty( !success );
+                        monitor.done();
+                    }
+                    catch ( Exception e )
+                    {
+                        MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+                            .getShell(), SWT.OK | SWT.ICON_ERROR );
+                        messageBox.setText( "Error!" );
+                        messageBox.setMessage( "An error occurred when writing the file to
disk." + "\n"
+                            + e.getMessage() );
+                        messageBox.open();
+                        setDirty( true );
+                        monitor.done();
+                        return;
+                    }
+                }
+            } );
+        }
+        catch ( Exception e )
+        {
+            MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+                SWT.OK | SWT.ICON_ERROR );
+            messageBox.setText( "Error!" );
+            messageBox.setMessage( "An error occurred when saving the file." + "\n" + e.getMessage()
);
+            messageBox.open();
+            return;
+        }
+    }
+
+
+    /**
+     * Performs the "Save as..." action.
+     *
+     * @param monitor
+     *      the monitor to use
+     * @throws Exception
+     */
+    private boolean doSaveAs( IProgressMonitor monitor ) throws Exception
+    {
+        // detect IDE or RCP:
+        // check if perspective org.eclipse.ui.resourcePerspective is available
+        boolean isIDE = PluginUtils.isIDEEnvironment();
+
+        if ( isIDE )
+        {
+            // Asking the user for the location where to 'save as' the file
+            SaveAsDialog dialog = new SaveAsDialog( getSite().getShell() );
+            if ( !( getEditorInput() instanceof NonExistingServerConfigurationInput ) )
+            {
+                dialog.setOriginalFile( ResourcesPlugin.getWorkspace().getRoot().getFile(
+                    new Path( getEditorInput().getToolTipText() ) ) );
+            }
+            if ( dialog.open() != Dialog.OK )
+            {
+                return false;
+            }
+
+            // Getting if the resulting file
+            IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile( dialog.getResult()
);
+
+            // Creating the file if it does not exist
+            if ( !file.exists() )
+            {
+                file.create( new ByteArrayInputStream( "".getBytes() ), true, null );
+            }
+
+            // Creating the new input for the editor
+            FileEditorInput fei = new FileEditorInput( file );
+
+            // Saving the file to disk
+            saveEditorPages( monitor );
+            saveConfiguration( fei, monitor );
+
+            // Setting the new input to the editor
+            setInput( fei );
+        }
+        else
+        {
+            Shell shell = getSite().getShell();
+            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 = "The file '" + path
+                        + "' already exists. Do you want to replace the existing file?";
+                    MessageDialog overwriteDialog = new MessageDialog( shell, "Question",
null, question,
+                        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 file to disk
+            saveEditorPages( monitor );
+            saveConfiguration( path );
+
+            // Creating the new input for the editor
+            PathEditorInput newInput = new PathEditorInput( new Path( path ) );
+
+            // Setting the new input to the editor
+            setInput( newInput );
+        }
+
+        // Updating the title and tooltip texts
+        setPartName( getEditorInput().getName() );
+
+        return true;
     }
 
 
@@ -325,5 +497,145 @@
     public ServerConfiguration getServerConfiguration()
     {
         return serverConfiguration;
+    }
+}
+
+/**
+ * This IEditorInput is used to open files that are located in the local file system.
+ * 
+ * Inspired from org.eclipse.ui.internal.editors.text.NonExistingFileEditorInput.java
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+class PathEditorInput implements IPathEditorInput
+{
+    /** The absolute path in local file system */
+    private IPath path;
+
+
+    /**
+     * 
+     * Creates a new instance of PathEditorInput.
+     *
+     * @param path the absolute path
+     */
+    public PathEditorInput( IPath path )
+    {
+        if ( path == null )
+        {
+            throw new IllegalArgumentException();
+        }
+
+        this.path = path;
+    }
+
+
+    /**
+     * Returns hash code of the path.
+     */
+    public int hashCode()
+    {
+        return path.hashCode();
+    }
+
+
+    /** 
+     * This implemention just compares the paths
+     */
+    public boolean equals( Object o )
+    {
+        if ( this == o )
+        {
+            return true;
+        }
+
+        if ( o instanceof PathEditorInput )
+        {
+            PathEditorInput input = ( PathEditorInput ) o;
+            return path.equals( input.path );
+        }
+
+        return false;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean exists()
+    {
+        return path.toFile().exists();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor( path.toString()
);
+    }
+
+
+    /**
+     * Returns the file name only.
+     */
+    public String getName()
+    {
+        return path.toFile().getName();
+        //return path.toString();
+    }
+
+
+    /**
+     * Returns the complete path. 
+     */
+    public String getToolTipText()
+    {
+        return path.makeRelative().toOSString();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public IPath getPath()
+    {
+        return path;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings("unchecked")
+    public Object getAdapter( Class adapter )
+    {
+        return Platform.getAdapterManager().getAdapter( this, adapter );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public IPersistableElement getPersistable()
+    {
+        return null;
+    }
+
+
+    /**
+     * Returns the path.
+     */
+    public IPath getPath( Object element )
+    {
+        if ( element instanceof PathEditorInput )
+        {
+            PathEditorInput input = ( PathEditorInput ) element;
+            return input.getPath();
+        }
+
+        return null;
     }
 }

Modified: directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerConfigurationWriter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerConfigurationWriter.java?rev=607060&r1=607059&r2=607060&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerConfigurationWriter.java
(original)
+++ directory/sandbox/felixk/studio-apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/ServerConfigurationWriter.java
Thu Dec 27 04:43:15 2007
@@ -581,6 +581,11 @@
         propertyElement = partitionBean.addElement( "property" );
         propertyElement.addAttribute( "name", "suffix" );
         propertyElement.addAttribute( "value", partition.getSuffix() );
+        
+        // PartitionClassName
+        propertyElement = partitionBean.addElement( "property" );
+        propertyElement.addAttribute( "name", "partitionClassName" );
+        propertyElement.addAttribute( "value", "org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition"
);
 
         // OptimizerEnabled
         propertyElement = partitionBean.addElement( "property" );

Modified: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/resources/org/apache/directory/studio/ldapbrowser/core/browsercoremessages.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/resources/org/apache/directory/studio/ldapbrowser/core/browsercoremessages.properties?rev=607060&r1=607059&r2=607060&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/resources/org/apache/directory/studio/ldapbrowser/core/browsercoremessages.properties
(original)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/resources/org/apache/directory/studio/ldapbrowser/core/browsercoremessages.properties
Thu Dec 27 04:43:15 2007
@@ -15,7 +15,7 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-copy_n_of_s=Copy {0}of {1}
+copy_n_of_s=Copy {0} of {1}
 
 event__added_att_to_dn=Added {0} to {1}
 event__deleted_att_from_dn=Deleted {0} from {1}
@@ -115,8 +115,8 @@
 jobs__check_bind_name=Check Authentication
 jobs__check_bind_task=Checking authentication
 jobs__check_bind_error=The authentication failed
-jobs__check_network_name=Check Network Parameter
-jobs__check_network_task=Checking network parameter
+jobs__check_network_name=Check network parameters
+jobs__check_network_task=Checking network parameters
 jobs__check_network_error=The connection failed
 
 jobs__fetch_basedns_name=Fetch Base DNs



Mime
View raw message