directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r559064 - in /directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor: controller/actions/ view/editors/attributetype/
Date Tue, 24 Jul 2007 14:39:27 GMT
Author: pamarcelot
Date: Tue Jul 24 07:39:26 2007
New Revision: 559064

URL: http://svn.apache.org/viewvc?view=rev&rev=559064
Log:
Added a confirmation before deleting anything in the SchemaView.

Modified:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/DeleteSchemaElementAction.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/DeleteSchemaElementAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/DeleteSchemaElementAction.java?view=diff&rev=559064&r1=559063&r2=559064
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/DeleteSchemaElementAction.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/DeleteSchemaElementAction.java
Tue Jul 24 07:39:26 2007
@@ -43,8 +43,11 @@
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 
 
@@ -118,53 +121,85 @@
 
         if ( !selection.isEmpty() )
         {
-            Map<String, Schema> schemasMap = new HashMap<String, Schema>();
-            List<SchemaObject> schemaObjectsList = new ArrayList<SchemaObject>();
-
-            for ( Iterator<?> iterator = selection.iterator(); iterator.hasNext();
)
+            MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+                SWT.YES | SWT.NO | SWT.ICON_QUESTION );
+            int count = selection.size();
+            if ( count == 1 )
             {
-                Object selectedItem = iterator.next();
-                if ( selectedItem instanceof SchemaWrapper )
+                Object firstElement = selection.getFirstElement();
+                if ( firstElement instanceof AttributeTypeWrapper )
                 {
-                    Schema schema = ( ( SchemaWrapper ) selectedItem ).getSchema();
-                    schemasMap.put( schema.getName().toLowerCase(), schema );
+                    messageBox.setMessage( "Are you sure you want to delete this attribute
type?" );
                 }
-                else if ( selectedItem instanceof AttributeTypeWrapper )
+                else if ( firstElement instanceof ObjectClassWrapper )
                 {
-                    AttributeTypeImpl at = ( ( AttributeTypeWrapper ) selectedItem ).getAttributeType();
-                    schemaObjectsList.add( at );
+                    messageBox.setMessage( "Are you sure you want to delete this object class?"
);
                 }
-                else if ( selectedItem instanceof ObjectClassWrapper )
+                else if ( firstElement instanceof SchemaWrapper )
                 {
-                    ObjectClassImpl oc = ( ( ObjectClassWrapper ) selectedItem ).getObjectClass();
-                    schemaObjectsList.add( oc );
+                    messageBox.setMessage( "Are you sure you want to delete this schema?"
);
+                }
+                else
+                {
+                    messageBox.setMessage( "Are you sure you want to delete this item?" );
                 }
-            }
 
-            SchemaHandler schemaHandler = Activator.getDefault().getSchemaHandler();
-            // Removing schema objects
-            for ( SchemaObject schemaObject : schemaObjectsList )
+            }
+            else
             {
-                if ( !schemasMap.containsKey( schemaObject.getSchema().toLowerCase() ) )
+                messageBox.setMessage( "Are you sure you want to delete these " + count +
" items?" );
+            }
+            if ( messageBox.open() == SWT.YES )
+            {
+
+                Map<String, Schema> schemasMap = new HashMap<String, Schema>();
+                List<SchemaObject> schemaObjectsList = new ArrayList<SchemaObject>();
+
+                for ( Iterator<?> iterator = selection.iterator(); iterator.hasNext();
)
                 {
-                    // If the schema object is not part of deleted schema, we need to delete
it.
-                    // But, we don't delete schema objects that are part of a deleted schema,
since
-                    // deleting the schema will also delete this schema object.
-                    if ( schemaObject instanceof AttributeTypeImpl )
+                    Object selectedItem = iterator.next();
+                    if ( selectedItem instanceof SchemaWrapper )
                     {
-                        schemaHandler.removeAttributeType( ( AttributeTypeImpl ) schemaObject
);
+                        Schema schema = ( ( SchemaWrapper ) selectedItem ).getSchema();
+                        schemasMap.put( schema.getName().toLowerCase(), schema );
                     }
-                    else if ( schemaObject instanceof ObjectClassImpl )
+                    else if ( selectedItem instanceof AttributeTypeWrapper )
                     {
-                        schemaHandler.removeObjectClass( ( ObjectClassImpl ) schemaObject
);
+                        AttributeTypeImpl at = ( ( AttributeTypeWrapper ) selectedItem ).getAttributeType();
+                        schemaObjectsList.add( at );
+                    }
+                    else if ( selectedItem instanceof ObjectClassWrapper )
+                    {
+                        ObjectClassImpl oc = ( ( ObjectClassWrapper ) selectedItem ).getObjectClass();
+                        schemaObjectsList.add( oc );
                     }
                 }
-            }
 
-            // Removing schemas
-            for ( Schema schema : schemasMap.values() )
-            {
-                schemaHandler.removeSchema( schema );
+                SchemaHandler schemaHandler = Activator.getDefault().getSchemaHandler();
+                // Removing schema objects
+                for ( SchemaObject schemaObject : schemaObjectsList )
+                {
+                    if ( !schemasMap.containsKey( schemaObject.getSchema().toLowerCase()
) )
+                    {
+                        // If the schema object is not part of deleted schema, we need to
delete it.
+                        // But, we don't delete schema objects that are part of a deleted
schema, since
+                        // deleting the schema will also delete this schema object.
+                        if ( schemaObject instanceof AttributeTypeImpl )
+                        {
+                            schemaHandler.removeAttributeType( ( AttributeTypeImpl ) schemaObject
);
+                        }
+                        else if ( schemaObject instanceof ObjectClassImpl )
+                        {
+                            schemaHandler.removeObjectClass( ( ObjectClassImpl ) schemaObject
);
+                        }
+                    }
+                }
+
+                // Removing schemas
+                for ( Schema schema : schemasMap.values() )
+                {
+                    schemaHandler.removeSchema( schema );
+                }
             }
         }
     }

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java?view=diff&rev=559064&r1=559063&r2=559064
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java
Tue Jul 24 07:39:26 2007
@@ -1091,6 +1091,7 @@
         aliasesButton.addSelectionListener( aliasesButtonListener );
         oidText.addModifyListener( oidTextModifyListener );
         oidText.addVerifyListener( oidTextVerifyListener );
+        schemaLink.addHyperlinkListener( schemaLinkListener );
         descriptionText.addModifyListener( descriptionTextListener );
         supLabel.addHyperlinkListener( supLabelListener );
         supCombo.addModifyListener( supComboListener );
@@ -1105,8 +1106,6 @@
         equalityCombo.addModifyListener( equalityComboListener );
         orderingCombo.addModifyListener( orderingComboListener );
         substringCombo.addModifyListener( substringComboListener );
-        schemaLink.addHyperlinkListener( schemaLinkListener );
-        supLabel.addHyperlinkListener( supLabelListener );
     }
 
 
@@ -1115,9 +1114,9 @@
      */
     private void removeListeners()
     {
+        aliasesButton.removeSelectionListener( aliasesButtonListener );
         oidText.removeModifyListener( oidTextModifyListener );
         oidText.removeVerifyListener( oidTextVerifyListener );
-        aliasesButton.removeSelectionListener( aliasesButtonListener );
         schemaLink.removeHyperlinkListener( schemaLinkListener );
         descriptionText.removeModifyListener( descriptionTextListener );
         supLabel.removeHyperlinkListener( supLabelListener );



Mime
View raw message