You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2008/08/09 10:33:24 UTC
svn commit: r684194 - in /directory/studio/trunk:
ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/
ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/
ldapbrowser-core/src/mai...
Author: seelmann
Date: Sat Aug 9 01:33:24 2008
New Revision: 684194
URL: http://svn.apache.org/viewvc?rev=684194&view=rev
Log:
Fix for DIRSTUDIO-365: Added option to the delete dialog to enable/disable tree delete control
Added:
directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/DeleteDialog.java
Modified:
directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java
directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java
directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java
directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java
Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java?rev=684194&r1=684193&r2=684194&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java Sat Aug 9 01:33:24 2008
@@ -35,6 +35,7 @@
import org.apache.directory.shared.ldap.name.AttributeTypeAndValue;
import org.apache.directory.shared.ldap.schema.syntax.AttributeTypeDescription;
import org.apache.directory.shared.ldap.schema.syntax.ObjectClassDescription;
+import org.apache.directory.studio.ldapbrowser.common.dialogs.DeleteDialog;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
import org.apache.directory.studio.ldapbrowser.core.jobs.DeleteAttributesValueJob;
import org.apache.directory.studio.ldapbrowser.core.jobs.DeleteEntriesJob;
@@ -47,7 +48,6 @@
import org.apache.directory.studio.ldapbrowser.core.model.IValue;
import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
@@ -75,28 +75,28 @@
IAttribute[] attributes = getAttributes();
IValue[] values = getValues();
- if ( entries.length > 0 && searches.length == 0 && bookmarks.length == 0
- && attributes.length == 0 && values.length == 0 )
+ if ( entries.length > 0 && searches.length == 0 && bookmarks.length == 0 && attributes.length == 0
+ && values.length == 0 )
{
return entries.length > 1 ? "Delete Entries" : "Delete Entry";
}
- if ( searches.length > 0 && entries.length == 0 && bookmarks.length == 0
- && attributes.length == 0 && values.length == 0 )
+ if ( searches.length > 0 && entries.length == 0 && bookmarks.length == 0 && attributes.length == 0
+ && values.length == 0 )
{
return searches.length > 1 ? "Delete Searches" : "Delete Search";
}
- if ( bookmarks.length > 0 && entries.length == 0 && searches.length == 0
- && attributes.length == 0 && values.length == 0 )
+ if ( bookmarks.length > 0 && entries.length == 0 && searches.length == 0 && attributes.length == 0
+ && values.length == 0 )
{
return bookmarks.length > 1 ? "Delete Bookmarks" : "Delete Bookmark";
}
- if ( attributes.length > 0 && entries.length == 0 && searches.length == 0
- && bookmarks.length == 0 && values.length == 0 )
+ if ( attributes.length > 0 && entries.length == 0 && searches.length == 0 && bookmarks.length == 0
+ && values.length == 0 )
{
return attributes.length > 1 ? "Delete Attributes" : "Delete Attribute";
}
- if ( values.length > 0 && entries.length == 0 && searches.length == 0
- && bookmarks.length == 0 && attributes.length == 0 )
+ if ( values.length > 0 && entries.length == 0 && searches.length == 0 && bookmarks.length == 0
+ && attributes.length == 0 )
{
return values.length > 1 ? "Delete Values" : "Delete Value";
}
@@ -141,6 +141,7 @@
IValue[] values = getValues();
StringBuffer message = new StringBuffer();
+ boolean askForTreeDeleteControl = false;
if ( entries.length > 0 )
{
@@ -162,6 +163,12 @@
}
message.append( BrowserCoreConstants.LINE_SEPARATOR );
message.append( BrowserCoreConstants.LINE_SEPARATOR );
+
+ if ( entries[0].getBrowserConnection().getRootDSE().isControlSupported(
+ org.apache.directory.studio.ldapbrowser.core.model.Control.TREEDELETE_CONTROL.getOid() ) )
+ {
+ askForTreeDeleteControl = true;
+ }
}
if ( searches.length > 0 )
@@ -259,11 +266,12 @@
}
}
- if ( message.length() == 0 || MessageDialog.openConfirm( getShell(), getText(), message.toString() ) )
+ DeleteDialog dialog = new DeleteDialog( getShell(), getText(), message.toString(), askForTreeDeleteControl );
+ if ( message.length() == 0 || dialog.open() == DeleteDialog.OK )
{
if ( entries.length > 0 )
{
- deleteEntries( entries );
+ deleteEntries( entries, dialog.isUseTreeDeleteControl() );
}
if ( searches.length > 0 )
{
@@ -333,8 +341,7 @@
IAttribute[] attributes = getAttributes();
IValue[] values = getValues();
- return entries.length + searches.length + bookmarks.length + attributes.length
- + values.length > 0;
+ return entries.length + searches.length + bookmarks.length + attributes.length + values.length > 0;
}
catch ( Exception e )
@@ -387,14 +394,14 @@
/**
- * Deletes Entries
- *
- * @param entries
- * the Entries to delete
+ * Deletes Entries.
+ *
+ * @param entries the Entries to delete
+ * @param useTreeDeleteControl true to use the tree delete control
*/
- protected void deleteEntries( IEntry[] entries )
+ protected void deleteEntries( IEntry[] entries, boolean useTreeDeleteControl )
{
- new DeleteEntriesJob( entries ).execute();
+ new DeleteEntriesJob( entries, useTreeDeleteControl ).execute();
}
Added: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/DeleteDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/DeleteDialog.java?rev=684194&view=auto
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/DeleteDialog.java (added)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/DeleteDialog.java Sat Aug 9 01:33:24 2008
@@ -0,0 +1,103 @@
+/*
+ * 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.ldapbrowser.common.dialogs;
+
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Dialog that prompts a user to delete items in the browser tree.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DeleteDialog extends MessageDialog
+{
+
+ private Button useTreeDeleteControlCheckbox;
+
+ private boolean askForTreeDeleteControl;
+
+ private boolean useTreeDeleteControl;
+
+
+ /**
+ * Instantiates a new delete dialog.
+ *
+ * @param parentShell the parent shell
+ * @param title the title
+ * @param message the message
+ * @param askForTreeDeleteControl true if the user should be asked if the tree delete control should be used
+ */
+ public DeleteDialog( Shell parentShell, String title, String message, boolean askForTreeDeleteControl )
+ {
+ super( parentShell, title, null, message, QUESTION, new String[]
+ { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, OK );
+
+ this.askForTreeDeleteControl = askForTreeDeleteControl;
+ this.useTreeDeleteControl = false;
+ }
+
+
+ @Override
+ protected Control createCustomArea( Composite parent )
+ {
+ if ( askForTreeDeleteControl )
+ {
+ useTreeDeleteControlCheckbox = new Button( parent, SWT.CHECK );
+ useTreeDeleteControlCheckbox.setText( "Use Tree Delete Control" );
+ return useTreeDeleteControlCheckbox;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ @Override
+ protected void buttonPressed( int buttonId )
+ {
+ if ( buttonId == OK )
+ {
+ useTreeDeleteControl = useTreeDeleteControlCheckbox != null && useTreeDeleteControlCheckbox.getSelection();
+ }
+ super.buttonPressed( buttonId );
+ }
+
+
+ /**
+ * Checks if tree delete control should be used.
+ *
+ * @return true, if tree delete control should be used
+ */
+ public boolean isUseTreeDeleteControl()
+ {
+ return useTreeDeleteControl;
+ }
+
+}
Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java?rev=684194&r1=684193&r2=684194&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java Sat Aug 9 01:33:24 2008
@@ -37,9 +37,9 @@
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.studio.connection.core.Connection;
-import org.apache.directory.studio.connection.core.jobs.StudioProgressMonitor;
import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
import org.apache.directory.studio.connection.core.Connection.ReferralHandlingMethod;
+import org.apache.directory.studio.connection.core.jobs.StudioProgressMonitor;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
import org.apache.directory.studio.ldapbrowser.core.events.ChildrenInitializedEvent;
import org.apache.directory.studio.ldapbrowser.core.events.EntryDeletedEvent;
@@ -73,7 +73,7 @@
/** The entries to delete. */
private IEntry[] entriesToDelete;
-
+
/** The deleted entries. */
private Set<IEntry> deletedEntriesSet;
@@ -83,15 +83,19 @@
/** The searches to update. */
private Set<ISearch> searchesToUpdateSet;
+ /** The use tree delete control flag. */
+ private boolean useTreeDeleteControl;
+
/**
* Creates a new instance of DeleteEntriesJob.
*
* @param entriesToDelete the entries to delete
*/
- public DeleteEntriesJob( final IEntry[] entriesToDelete )
+ public DeleteEntriesJob( final IEntry[] entriesToDelete, boolean useTreeDeleteControl )
{
this.entriesToDelete = entriesToDelete;
+ this.useTreeDeleteControl = useTreeDeleteControl;
this.deletedEntriesSet = new HashSet<IEntry>();
this.entriesToUpdateSet = new HashSet<IEntry>();
@@ -140,7 +144,8 @@
// delete from directory
int errorStatusSize1 = monitor.getErrorStatus( "" ).getChildren().length; //$NON-NLS-1$
- num = optimisticDeleteEntryRecursive( browserConnection, entryToDelete.getDn(), num, dummyMonitor, monitor );
+ num = optimisticDeleteEntryRecursive( browserConnection, entryToDelete.getDn(), useTreeDeleteControl, num,
+ dummyMonitor, monitor );
int errorStatusSize2 = monitor.getErrorStatus( "" ).getChildren().length; //$NON-NLS-1$
if ( !monitor.isCanceled() )
@@ -207,6 +212,7 @@
*
* @param browserConnection the browser connection
* @param dn the DN to delete
+ * @param useTreeDeleteControl true to use the tree delete control
* @param numberOfDeletedEntries the number of deleted entries
* @param dummyMonitor the dummy monitor
* @param monitor the progress monitor
@@ -214,11 +220,12 @@
* @return the cumulative number of deleted entries
*/
static int optimisticDeleteEntryRecursive( IBrowserConnection browserConnection, LdapDN dn,
- int numberOfDeletedEntries, StudioProgressMonitor dummyMonitor, StudioProgressMonitor monitor )
+ boolean useTreeDeleteControl, int numberOfDeletedEntries, StudioProgressMonitor dummyMonitor,
+ StudioProgressMonitor monitor )
{
// try to delete entry
dummyMonitor.reset();
- deleteEntry( browserConnection, dn, dummyMonitor );
+ deleteEntry( browserConnection, dn, useTreeDeleteControl, dummyMonitor );
if ( !dummyMonitor.errorsReported() )
{
@@ -263,7 +270,7 @@
SearchResult sr = result.next();
LdapDN childDn = JNDIUtils.getDn( sr );
- numberOfDeletedEntries = optimisticDeleteEntryRecursive( browserConnection, childDn,
+ numberOfDeletedEntries = optimisticDeleteEntryRecursive( browserConnection, childDn, false,
numberOfDeletedEntries, dummyMonitor, monitor );
numberInBatch++;
}
@@ -288,7 +295,7 @@
// try to delete the entry again
if ( !dummyMonitor.errorsReported() )
{
- deleteEntry( browserConnection, dn, dummyMonitor );
+ deleteEntry( browserConnection, dn, false, dummyMonitor );
}
if ( !dummyMonitor.errorsReported() )
{
@@ -337,12 +344,14 @@
}
- static void deleteEntry( IBrowserConnection browserConnection, LdapDN dn, StudioProgressMonitor monitor )
+ static void deleteEntry( IBrowserConnection browserConnection, LdapDN dn, boolean useTreeDeleteControl,
+ StudioProgressMonitor monitor )
{
// controls
List<Control> controlList = new ArrayList<Control>();
- if ( browserConnection.getRootDSE().isControlSupported(
- org.apache.directory.studio.ldapbrowser.core.model.Control.TREEDELETE_CONTROL.getOid() ) )
+ if ( useTreeDeleteControl
+ && browserConnection.getRootDSE().isControlSupported(
+ org.apache.directory.studio.ldapbrowser.core.model.Control.TREEDELETE_CONTROL.getOid() ) )
{
Control treeDeleteControl = new BasicControl(
org.apache.directory.studio.ldapbrowser.core.model.Control.TREEDELETE_CONTROL.getOid(),
Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java?rev=684194&r1=684193&r2=684194&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java Sat Aug 9 01:33:24 2008
@@ -174,8 +174,8 @@
if ( !dummyMonitor.errorsReported() )
{
dummyMonitor.reset();
- numDel = DeleteEntriesJob.optimisticDeleteEntryRecursive( browserConnection, oldDn, numDel,
- dummyMonitor, monitor );
+ numDel = DeleteEntriesJob.optimisticDeleteEntryRecursive( browserConnection, oldDn, false,
+ numDel, dummyMonitor, monitor );
}
}
else
Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java?rev=684194&r1=684193&r2=684194&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryJob.java Sat Aug 9 01:33:24 2008
@@ -158,8 +158,8 @@
if ( !dummyMonitor.errorsReported() )
{
dummyMonitor.reset();
- DeleteEntriesJob.optimisticDeleteEntryRecursive( browserConnection, oldDn, 0, dummyMonitor,
- monitor );
+ DeleteEntriesJob.optimisticDeleteEntryRecursive( browserConnection, oldDn, false, 0,
+ dummyMonitor, monitor );
}
}
else