Commits

Anonymous committed f777eac

Renamed and added methods in CommonUIUtils.
Added the display of a warning message to the UnknownLdapServerAdapterExtension when the methods 'add()', 'openConfiguration()', 'start()' and 'stop()' are used.

git-svn-id: https://svn.apache.org/repos/asf/directory/studio/trunk@98635013f79535-47bb-0310-9956-ffa450edef68

  • Participants
  • Parent commits 24d1a52

Comments (0)

Files changed (4)

File plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/CommonUIUtils.java

 public class CommonUIUtils
 {
     /**
-     * Reports an error.
+     * Opens an Error {@link MessageDialog} with the given message.
      *
      * @param message
      *      the message
      */
-    public static void reportError( String message )
+    public static void openErrorDialog( String message )
+    {
+        openErrorDialog( "Error!", message );
+    }
+
+
+    /**
+     * Opens an Error {@link MessageDialog} with the given title and message.
+     *
+     * @param title
+     *      the title
+     * @param message
+     *      the message
+     */
+    public static void openErrorDialog( String title, String message )
+    {
+        MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+            title, null, message, MessageDialog.ERROR, new String[]
+                { IDialogConstants.OK_LABEL }, MessageDialog.OK );
+        dialog.open();
+    }
+
+
+    /**
+     * Opens an Information {@link MessageDialog} with the given message.
+     *
+     * @param message
+     *      the message
+     */
+    public static void openInformationDialog( String message )
+    {
+        openInformationDialog( "Information", message );
+    }
+
+
+    /**
+     * Opens an Information {@link MessageDialog} with the given title and message.
+     *
+     * @param title
+     *      the title
+     * @param message
+     *      the message
+     */
+    public static void openInformationDialog( String title, String message )
+    {
+        MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+            title, null, message, MessageDialog.INFORMATION, new String[]
+                { IDialogConstants.OK_LABEL }, MessageDialog.OK );
+        dialog.open();
+    }
+
+
+    /**
+     * Opens an Warning {@link MessageDialog} with the given message.
+     *
+     * @param message
+     *      the message
+     */
+    public static void openWarningDialog( String message )
+    {
+        openInformationDialog( "Information", message );
+    }
+
+
+    /**
+     * Opens an Warning {@link MessageDialog} with the given title and message.
+     *
+     * @param title
+     *      the title
+     * @param message
+     *      the message
+     */
+    public static void openWarningDialog( String title, String message )
     {
         MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
-            "Error!", null, message, MessageDialog.ERROR, new String[]
+            title, null, message, MessageDialog.WARNING, new String[]
                 { IDialogConstants.OK_LABEL }, MessageDialog.OK );
         dialog.open();
     }

File plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersManager.java

                     }
                     catch ( Exception e )
                     {
-                        CommonUIUtils.reportError( Messages.getString( "LdapServersManager.ErrorLoadingServer" ) //$NON-NLS-1$
+                        CommonUIUtils.openErrorDialog( Messages.getString( "LdapServersManager.ErrorLoadingServer" ) //$NON-NLS-1$
                             + e.getMessage() );
                     }
                 }
                 else
                 {
-                    CommonUIUtils.reportError( Messages.getString( "LdapServersManager.ErrorLoadingServer" ) //$NON-NLS-1$
+                    CommonUIUtils.openErrorDialog( Messages.getString( "LdapServersManager.ErrorLoadingServer" ) //$NON-NLS-1$
                         + exceptionMessage );
                 }
             }
             catch ( Exception e )
             {
                 CommonUIUtils
-                    .reportError( Messages.getString( "LdapServersManager.ErrorLoadingServer" ) + e.getMessage() ); //$NON-NLS-1$
+                    .openErrorDialog( Messages.getString( "LdapServersManager.ErrorLoadingServer" ) + e.getMessage() ); //$NON-NLS-1$
             }
         }
     }

File plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersUtils.java

                 }
                 catch ( IOException e )
                 {
-                    CommonUIUtils.reportError( "An error occurred when copying the library '" + library
+                    CommonUIUtils.openErrorDialog( "An error occurred when copying the library '" + library
                         + "' to the location '" + destinationLibraryFile.getAbsolutePath() + "'.\n\n" + e.getMessage() );
                 }
             }

File plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/UnknownLdapServerAdapterExtension.java

 
 import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
 import org.apache.directory.studio.common.ui.CommonUIUtils;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
 
 
 /**
              */
             public void add( LdapServer server, StudioProgressMonitor monitor ) throws Exception
             {
-                // Will never occur
+                showWarningDialog();
             }
 
 
              */
             public void openConfiguration( LdapServer server, StudioProgressMonitor monitor ) throws Exception
             {
-                Display.getDefault().asyncExec( new Runnable()
-                {
-                    public void run()
-                    {
-                        // TODO
-                    }
-                } );
+                showWarningDialog();
             }
 
 
              */
             public void start( LdapServer server, StudioProgressMonitor monitor ) throws Exception
             {
-                throw new Exception(
-                    NLS.bind(
-                        "This server was created with a server adapter which is no longer available. You need install it (again) using the update site of the vendor. \nServer adapter information: ID=''{0}'', Name=''{1}'', Vendor=''{2}'', Version=''{3}''",
-                        new String[]
-                            { getId(), getName(), getVendor(), getVersion() } ) );
+                showWarningDialog();
+
+                server.setStatus( LdapServerStatus.STOPPED );
             }
 
 
              */
             public void stop( LdapServer server, StudioProgressMonitor monitor ) throws Exception
             {
-                // Will never occur
+                showWarningDialog();
+
+                server.setStatus( LdapServerStatus.STOPPED );
+            }
+
+
+            /**
+             * Shows the warning dialog.
+             */
+            private void showWarningDialog()
+            {
+                Display.getDefault().asyncExec( new Runnable()
+                {
+                    public void run()
+                    {
+                        CommonUIUtils.openWarningDialog(
+                            "Server Adapter Not Available",
+                            NLS.bind(
+                                "This server was created with a server adapter which is no longer available. You need install it (again) using the update site of the vendor. \n\nServer adapter information: ID=''{0}'', Name=''{1}'', Vendor=''{2}'', Version=''{3}''",
+                                new String[]
+                                    { getId(), getName(), getVendor(), getVersion() } ) );
+                    }
+                } );
             }
         } );
+
     }
 }