Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 22676 invoked from network); 18 May 2008 11:12:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 May 2008 11:12:25 -0000 Received: (qmail 62327 invoked by uid 500); 18 May 2008 11:12:26 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 62287 invoked by uid 500); 18 May 2008 11:12:26 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 62278 invoked by uid 99); 18 May 2008 11:12:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 May 2008 04:12:26 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 May 2008 11:11:47 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B15DC23889FE; Sun, 18 May 2008 04:12:02 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r657537 [1/2] - in /directory/studio/trunk: connection-core/ connection-core/src/main/java/org/apache/directory/studio/connection/core/ connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/ ldapbrowser-core/src/... Date: Sun, 18 May 2008 11:12:01 -0000 To: commits@directory.apache.org From: seelmann@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080518111202.B15DC23889FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: seelmann Date: Sun May 18 04:12:00 2008 New Revision: 657537 URL: http://svn.apache.org/viewvc?rev=657537&view=rev Log: DIRSTUDIO-328: Added log view for search requests and results Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/proxy/SearchLogsViewActionProxy.java directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/SearchLogsPreferencePage.java directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/ClearAction.java directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchRequestLogsAction.java directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchResultEntryLogsAction.java directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/NewerAction.java directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/OlderAction.java directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/OpenSearchLogsPreferencePageAction.java directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/RefreshAction.java directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsView.java directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsViewActionGroup.java directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsViewInput.java directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsViewUniversalListener.java Modified: directory/studio/trunk/connection-core/plugin.xml directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCoreConstants.java directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePlugin.java directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePreferencesInitializer.java directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionManager.java directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/IJndiLogger.java directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/Utils.java directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioNamingEnumeration.java directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java directory/studio/trunk/ldapbrowser-ui/plugin.xml directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIConstants.java directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/perspective/BrowserPerspective.java directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewUniversalListener.java directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OpenModificationLogsPreferencePageAction.java Modified: directory/studio/trunk/connection-core/plugin.xml URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/plugin.xml?rev=657537&r1=657536&r2=657537&view=diff ============================================================================== --- directory/studio/trunk/connection-core/plugin.xml (original) +++ directory/studio/trunk/connection-core/plugin.xml Sun May 18 04:12:00 2008 @@ -29,6 +29,12 @@ id="org.apache.directory.studio.connection.core.io.jndi.LdifModificationLogger" name="LDIF Modification Logger"> + + Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCoreConstants.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCoreConstants.java?rev=657537&r1=657536&r2=657537&view=diff ============================================================================== --- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCoreConstants.java (original) +++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCoreConstants.java Sun May 18 04:12:00 2008 @@ -38,4 +38,10 @@ /** The constant used to identify the "enable modification logs" preference */ public static final String PREFERENCE_MODIFICATIONLOGS_ENABLE = "modificationLogsEnable"; + /** The constant used to identify the "enable search request logs" preference */ + public static final String PREFERENCE_SEARCHREQUESTLOGS_ENABLE = "searchRequestLogsEnable"; + + /** The constant used to identify the "enable search result entry logs" preference */ + public static final String PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE = "searchResultEntryLogsEnable"; + } Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePlugin.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePlugin.java?rev=657537&r1=657536&r2=657537&view=diff ============================================================================== --- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePlugin.java (original) +++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePlugin.java Sun May 18 04:12:00 2008 @@ -26,6 +26,7 @@ import org.apache.directory.studio.connection.core.event.CoreEventRunner; import org.apache.directory.studio.connection.core.event.EventRunner; import org.apache.directory.studio.connection.core.io.jndi.LdifModificationLogger; +import org.apache.directory.studio.connection.core.io.jndi.LdifSearchLogger; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionRegistry; @@ -242,6 +243,25 @@ } return null; } + + + /** + * Gets the LDIF search logger. + * + * @return the LDIF search logger, null if none found. + */ + public LdifSearchLogger getLdifSearchLogger() + { + List jndiLoggers = getJndiLoggers(); + for ( IJndiLogger jndiLogger : jndiLoggers ) + { + if(jndiLogger instanceof LdifSearchLogger) + { + return ( LdifSearchLogger ) jndiLogger; + } + } + return null; + } /** Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePreferencesInitializer.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePreferencesInitializer.java?rev=657537&r1=657536&r2=657537&view=diff ============================================================================== --- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePreferencesInitializer.java (original) +++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePreferencesInitializer.java Sun May 18 04:12:00 2008 @@ -42,6 +42,10 @@ // Modification Logs preferences.setDefault( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE, true ); + + // Search Logs + preferences.setDefault( ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE, true ); + preferences.setDefault( ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE, false ); } } Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionManager.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionManager.java?rev=657537&r1=657536&r2=657537&view=diff ============================================================================== --- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionManager.java (original) +++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionManager.java Sun May 18 04:12:00 2008 @@ -83,6 +83,27 @@ /** + * Gets the Search Log filename for the corresponding connection. + * + * @param connection + * the connection + * @return + * the Search Log filename + */ + public static final String getSearchLogFileName( Connection connection ) + { + IPath p = ConnectionCorePlugin.getDefault().getStateLocation().append( "logs" ); //$NON-NLS-1$ + File file = p.toFile(); + if ( !file.exists() ) + { + file.mkdir(); + } + return p + .append( "search-" + Utils.getFilenameString( connection.getId() ) + "-%u-%g.ldiflog" ).toOSString(); //$NON-NLS-1$ //$NON-NLS-2$ + } + + + /** * Gets the filename of the Connection Store. * * @return Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/IJndiLogger.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/IJndiLogger.java?rev=657537&r1=657536&r2=657537&view=diff ============================================================================== --- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/IJndiLogger.java (original) +++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/IJndiLogger.java Sun May 18 04:12:00 2008 @@ -23,8 +23,12 @@ import javax.naming.NamingException; import javax.naming.directory.Attributes; import javax.naming.directory.ModificationItem; +import javax.naming.directory.SearchControls; import javax.naming.ldap.Control; +import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod; +import org.apache.directory.studio.connection.core.io.jndi.StudioSearchResult; + /** * Callback interface to log modifications @@ -44,7 +48,8 @@ * @param controls the controls * @param ex the naming exception if an error occurred, null otherwise */ - public void logChangetypeAdd( Connection connection, final String dn, final Attributes attributes, final Control[] controls, NamingException ex ); + public void logChangetypeAdd( Connection connection, final String dn, final Attributes attributes, + final Control[] controls, NamingException ex ); /** @@ -56,7 +61,8 @@ * @param ex the naming exception if an error occurred, null otherwise * */ - public void logChangetypeDelete( Connection connection, final String dn, final Control[] controls, NamingException ex ); + public void logChangetypeDelete( Connection connection, final String dn, final Control[] controls, + NamingException ex ); /** @@ -68,7 +74,8 @@ * @param ex the naming exception if an error occurred, null otherwise * @param controls the controls */ - public void logChangetypeModify( Connection connection, final String dn, final ModificationItem[] modificationItems, final Control[] controls, NamingException ex ); + public void logChangetypeModify( Connection connection, final String dn, + final ModificationItem[] modificationItems, final Control[] controls, NamingException ex ); /** @@ -81,7 +88,8 @@ * @param controls the controls * @param ex the naming exception if an error occurred, null otherwise */ - public void logChangetypeModDn( Connection connection, final String oldDn, final String newDn, final boolean deleteOldRdn, final Control[] controls, NamingException ex ); + public void logChangetypeModDn( Connection connection, final String oldDn, final String newDn, + final boolean deleteOldRdn, final Control[] controls, NamingException ex ); /** @@ -98,8 +106,8 @@ * @return the logger ID */ public String getId(); - - + + /** * Sets the logger name. * @@ -114,16 +122,16 @@ * @return the logger name */ public String getName(); - - + + /** * Sets the logger description. * * @param description the new logger description */ public void setDescription( String description ); - - + + /** * Gets the logger description. * @@ -131,4 +139,44 @@ */ public String getDescription(); + + /** + * Logs a search request. + * + * @param connection the connection + * @param searchBase the search base + * @param filter the filter + * @param searchControls the search controls + * @param aliasesDereferencingMethod the aliases dereferncing method + * @param controls the LDAP controls + * @param requestNum the request number + * @param namingException the naming exception if an error occurred, null otherwise + */ + public void logSearchRequest( Connection connection, String searchBase, String filter, + SearchControls searchControls, AliasDereferencingMethod aliasesDereferencingMethod, Control[] controls, + long requestNum, NamingException namingException ); + + + /** + * Logs a search result entry. + * + * @param connection the connection + * @param studioSearchResult the search result + * @param requestNum the request number + * @param the naming exception if an error occurred, null otherwise + */ + public void logSearchResultEntry( Connection connection, StudioSearchResult studioSearchResult, long requestNum, + NamingException namingException ); + + + /** + * Logs a search result done. + * + * @param connection the connection + * @param count the number of received entries + * @param requestNum the request number + * @param the naming exception if an error occurred, null otherwise + */ + public void logSearchResultDone( Connection connection, long count, long requestNum, NamingException namingException ); + } Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/Utils.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/Utils.java?rev=657537&r1=657536&r2=657537&view=diff ============================================================================== --- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/Utils.java (original) +++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/Utils.java Sun May 18 04:12:00 2008 @@ -20,7 +20,17 @@ package org.apache.directory.studio.connection.core; + +import java.util.Arrays; + +import javax.naming.InvalidNameException; +import javax.naming.directory.SearchControls; + +import org.apache.directory.shared.ldap.codec.util.LdapURL; +import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.directory.shared.ldap.util.StringTools; +import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod; +import org.apache.directory.studio.connection.core.ConnectionParameter.EncryptionMethod; /** @@ -78,7 +88,6 @@ return sb.toString(); } - /** * Converts a String into a String that could be used as a filename. @@ -95,7 +104,6 @@ return null; } - byte[] b = StringTools.getBytesUtf8( s ); StringBuffer sb = new StringBuffer(); for ( int i = 0; i < b.length; i++ ) @@ -121,4 +129,128 @@ return sb.toString(); } + + /** + * Transforms the given search parameters into an LDAP URL. + * + * @param connection the connection + * @param searchBase the search base + * @param scope the search scope + * @param filter the search filter + * @param attributes the returning attributes + * + * @return the LDAP URL for the given search parameters + */ + public static LdapURL getLdapURL( Connection connection, String searchBase, int scope, String filter, + String[] attributes ) + { + LdapURL url = new LdapURL(); + url.setScheme( connection.getEncryptionMethod() == EncryptionMethod.LDAPS ? "ldaps://" : "ldap://" ); + url.setHost( connection.getHost() ); + url.setPort( connection.getPort() ); + try + { + url.setDn( new LdapDN( searchBase ) ); + } + catch ( InvalidNameException e ) + { + } + url.setAttributes( Arrays.asList( attributes ) ); + url.setScope( scope ); + url.setFilter( filter ); + return url; + } + + + /** + * Transforms the given search parameters into an ldapsearch command line. + * + * @param connection the connection + * @param searchBase the search base + * @param scope the search scope + * @param aliasesDereferencingMethod the aliases dereferencing method + * @param sizeLimit the size limit + * @param timeLimit the time limit + * @param filter the search filter + * @param attributes the returning attributes + * + * @return the ldapsearch command line for the given search parameters + */ + public static String getLdapSearchCommandLine( Connection connection, String searchBase, int scope, + AliasDereferencingMethod aliasesDereferencingMethod, long sizeLimit, long timeLimit, String filter, + String[] attributes ) + { + StringBuilder cmdLine = new StringBuilder(); + + cmdLine.append( "ldapsearch" ); + + cmdLine.append( " -H " ).append( + connection.getEncryptionMethod() == EncryptionMethod.LDAPS ? "ldaps://" : "ldap://" ).append( + connection.getHost() ).append( ":" ).append( connection.getPort() ); + + if ( connection.getEncryptionMethod() == EncryptionMethod.START_TLS ) + { + cmdLine.append( " -ZZ" ); + } + + switch ( connection.getAuthMethod() ) + { + case SIMPLE: + cmdLine.append( " -x" ); + cmdLine.append( " -D \"" ).append( connection.getBindPrincipal() ).append( "\"" ); + cmdLine.append( " -W" ); + break; + case SASL_CRAM_MD5: + cmdLine.append( " -U \"" ).append( connection.getBindPrincipal() ).append( "\"" ); + cmdLine.append( " -Y \"CRAM-MD5\"" ); + break; + case SASL_DIGEST_MD5: + cmdLine.append( " -U \"" ).append( connection.getBindPrincipal() ).append( "\"" ); + cmdLine.append( " -Y \"DIGEST-MD5\"" ); + break; + case SASL_GSSAPI: + cmdLine.append( " -Y \"GSSAPI\"" ); + break; + } + + cmdLine.append( " -b \"" ).append( searchBase ).append( "\"" ); + + String scopeAsString = scope == SearchControls.SUBTREE_SCOPE ? "sub" + : scope == SearchControls.ONELEVEL_SCOPE ? "one" : "base"; + cmdLine.append( " -s " ).append( scopeAsString ); + + if ( aliasesDereferencingMethod != AliasDereferencingMethod.NEVER ) + { + String aliasAsString = aliasesDereferencingMethod == AliasDereferencingMethod.ALWAYS ? "always" + : aliasesDereferencingMethod == AliasDereferencingMethod.FINDING ? "find" + : aliasesDereferencingMethod == AliasDereferencingMethod.SEARCH ? "search" : "never"; + cmdLine.append( " -a " ).append( aliasAsString ); + } + + if ( sizeLimit > 0 ) + { + cmdLine.append( " -z " ).append( sizeLimit ); + } + if ( timeLimit > 0 ) + { + cmdLine.append( " -l " ).append( timeLimit ); + } + + cmdLine.append( " \"" ).append( filter ).append( "\"" ); + + if ( attributes != null ) + { + if ( attributes.length == 0 ) + { + cmdLine.append( " \"1.1\"" ); + } + for ( String attribute : attributes ) + { + cmdLine.append( " \"" ).append( attribute ).append( "\"" ); + } + } + + return cmdLine.toString(); + } + } Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java?rev=657537&r1=657536&r2=657537&view=diff ============================================================================== --- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java (original) +++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java Sun May 18 04:12:00 2008 @@ -84,6 +84,8 @@ public class JNDIConnectionWrapper implements ConnectionWrapper { + private static int SEARCH_RESQUEST_NUM = 0; + private Connection connection; private boolean useLdaps; @@ -285,6 +287,7 @@ { // add ManageDsaIT control Control[] localControls = addManageDsaItControls( controls, referralsHandlingMethod ); + long requestNum = SEARCH_RESQUEST_NUM++; try { @@ -299,10 +302,11 @@ searchCtx.addToEnvironment( Context.REFERRAL, REFERRAL_THROW ); // perform the search - namingEnumeration = searchCtx.search( new LdapName( searchBase ), filter, searchControls ); - namingEnumeration = new StudioNamingEnumeration( connection, namingEnumeration, searchBase, filter, - searchControls, aliasesDereferencingMethod, referralsHandlingMethod, controls, monitor, - referralsInfo ); + NamingEnumeration ne = searchCtx.search( new LdapName( searchBase ), filter, + searchControls ); + namingEnumeration = new StudioNamingEnumeration( connection, ne, searchBase, filter, + searchControls, aliasesDereferencingMethod, referralsHandlingMethod, controls, requestNum, + monitor, referralsInfo ); } catch ( PartialResultException pre ) { @@ -352,10 +356,10 @@ referralSearchControls.setDerefLinkFlag( searchControls.getDerefLinkFlag() ); referralSearchControls.setReturningObjFlag( searchControls.getReturningObjFlag() ); - namingEnumeration = referralConnection.getJNDIConnectionWrapper().search( - referralSearchBase, referralFilter, referralSearchControls, - aliasesDereferencingMethod, referralsHandlingMethod, controls, monitor, - newReferralsInfo ); + namingEnumeration = ( StudioNamingEnumeration ) referralConnection + .getJNDIConnectionWrapper().search( referralSearchBase, referralFilter, + referralSearchControls, aliasesDereferencingMethod, + referralsHandlingMethod, controls, monitor, newReferralsInfo ); } } } @@ -370,6 +374,21 @@ // report each other naming exception namingException = e; } + + for ( IJndiLogger logger : getJndiLoggers() ) + { + if ( namingEnumeration != null ) + { + logger.logSearchRequest( connection, searchBase, filter, searchControls, + aliasesDereferencingMethod, localControls, requestNum, namingException ); + } + else + { + logger.logSearchRequest( connection, searchBase, filter, searchControls, + aliasesDereferencingMethod, localControls, requestNum, namingException ); + logger.logSearchResultDone( connection, 0, requestNum, namingException ); + } + } } }; @@ -1063,7 +1082,7 @@ abstract class InnerRunnable implements Runnable { - protected NamingEnumeration namingEnumeration = null; + protected StudioNamingEnumeration namingEnumeration = null; protected NamingException namingException = null; Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java?rev=657537&r1=657536&r2=657537&view=diff ============================================================================== --- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java (original) +++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java Sun May 18 04:12:00 2008 @@ -43,6 +43,7 @@ import javax.naming.directory.Attributes; import javax.naming.directory.DirContext; import javax.naming.directory.ModificationItem; +import javax.naming.directory.SearchControls; import javax.naming.ldap.Control; import org.apache.directory.shared.ldap.name.LdapDN; @@ -53,6 +54,7 @@ import org.apache.directory.studio.connection.core.ConnectionManager; import org.apache.directory.studio.connection.core.DnUtils; import org.apache.directory.studio.connection.core.IJndiLogger; +import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod; import org.apache.directory.studio.ldifparser.LdifFormatParameters; import org.apache.directory.studio.ldifparser.model.container.LdifChangeAddRecord; import org.apache.directory.studio.ldifparser.model.container.LdifChangeDeleteRecord; @@ -73,7 +75,7 @@ /** - * The ModificationLogger is used to log modifications in LDIF format into a file. + * The LdifModificationLogger is used to log modifications in LDIF format into a file. * * @author Apache Directory Project * @version $Rev$, $Date$ @@ -98,7 +100,7 @@ /** - * Creates a new instance of ModificationLogger. + * Creates a new instance of LdifModificationLogger. */ public LdifModificationLogger() { @@ -217,12 +219,12 @@ /** - * @see org.apache.directory.studio.connection.core.IModificationLogger#logChangetypeAdd(java.lang.String, javax.naming.directory.Attributes, javax.naming.ldap.Control[], javax.naming.NamingException) + * @see org.apache.directory.studio.connection.core.IJndiLogger#logChangetypeAdd(org.apache.directory.studio.connection.core.Connection, java.lang.String, javax.naming.directory.Attributes, javax.naming.ldap.Control[], javax.naming.NamingException) */ public void logChangetypeAdd( Connection connection, final String dn, final Attributes attributes, final Control[] controls, NamingException ex ) { - if (!isModificationLogEnabled()) + if ( !isModificationLogEnabled() ) { return; } @@ -263,12 +265,12 @@ /** - * @see org.apache.directory.studio.connection.core.IModificationLogger#logChangetypeDelete(java.lang.String, javax.naming.ldap.Control[], javax.naming.NamingException) + * @see org.apache.directory.studio.connection.core.IJndiLogger#logChangetypeDelete(org.apache.directory.studio.connection.core.Connection, java.lang.String, javax.naming.ldap.Control[], javax.naming.NamingException) */ public void logChangetypeDelete( Connection connection, final String dn, final Control[] controls, NamingException ex ) { - if (!isModificationLogEnabled()) + if ( !isModificationLogEnabled() ) { return; } @@ -284,12 +286,12 @@ /** - * @see org.apache.directory.studio.connection.core.IModificationLogger#logChangetypeModify(java.lang.String, javax.naming.directory.ModificationItem[], javax.naming.ldap.Control[], javax.naming.NamingException) + * @see org.apache.directory.studio.connection.core.IJndiLogger#logChangetypeModify(org.apache.directory.studio.connection.core.Connection, java.lang.String, javax.naming.directory.ModificationItem[], javax.naming.ldap.Control[], javax.naming.NamingException) */ public void logChangetypeModify( Connection connection, final String dn, final ModificationItem[] modificationItems, final Control[] controls, NamingException ex ) { - if (!isModificationLogEnabled()) + if ( !isModificationLogEnabled() ) { return; } @@ -347,12 +349,12 @@ /** - * @see org.apache.directory.studio.connection.core.IModificationLogger#logChangetypeModDn(java.lang.String, java.lang.String, boolean, javax.naming.ldap.Control[], javax.naming.NamingException) + * @see org.apache.directory.studio.connection.core.IJndiLogger#logChangetypeModDn(org.apache.directory.studio.connection.core.Connection, java.lang.String, java.lang.String, boolean, javax.naming.ldap.Control[], javax.naming.NamingException) */ public void logChangetypeModDn( Connection connection, final String oldDn, final String newDn, final boolean deleteOldRdn, final Control[] controls, NamingException ex ) { - if (!isModificationLogEnabled()) + if ( !isModificationLogEnabled() ) { return; } @@ -381,6 +383,36 @@ /** + * @see org.apache.directory.studio.connection.core.IJndiLogger#logSearchRequest(org.apache.directory.studio.connection.core.Connection, java.lang.String, java.lang.String, javax.naming.directory.SearchControls, org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod, javax.naming.ldap.Control[], long, javax.naming.NamingException) + */ + public void logSearchRequest( Connection connection, String searchBase, String filter, + SearchControls searchControls, AliasDereferencingMethod aliasesDereferencingMethod, Control[] controls, + long requestNum, NamingException ex ) + { + // don't log searches + } + + + /** + * @see org.apache.directory.studio.connection.core.IJndiLogger#logSearchResultEntry(org.apache.directory.studio.connection.core.Connection, org.apache.directory.studio.connection.core.io.jndi.StudioSearchResult, long, javax.naming.NamingException) + */ + public void logSearchResultEntry( Connection connection, StudioSearchResult studioSearchResult, long requestNum, + NamingException ex ) + { + // don't log searches + } + + + /** + * @see org.apache.directory.studio.connection.core.IJndiLogger#logSearchResultDone(org.apache.directory.studio.connection.core.Connection, long, long, javax.naming.NamingException) + */ + public void logSearchResultDone( Connection connection, long count, long requestNum, NamingException namingException ) + { + // don't log searches + } + + + /** * Adds control lines to the record * * @param record the recored @@ -472,6 +504,7 @@ return null; } + /** * Checks if modification log is enabled. * @@ -479,10 +512,11 @@ */ private boolean isModificationLogEnabled() { - return ConnectionCorePlugin.getDefault().getPluginPreferences() - .getBoolean( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE ); + return ConnectionCorePlugin.getDefault().getPluginPreferences().getBoolean( + ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE ); } + public String getId() { return id; Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioNamingEnumeration.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioNamingEnumeration.java?rev=657537&r1=657536&r2=657537&view=diff ============================================================================== --- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioNamingEnumeration.java (original) +++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioNamingEnumeration.java Sun May 18 04:12:00 2008 @@ -30,6 +30,8 @@ import org.apache.directory.shared.ldap.codec.util.LdapURL; import org.apache.directory.studio.connection.core.Connection; +import org.apache.directory.studio.connection.core.ConnectionCorePlugin; +import org.apache.directory.studio.connection.core.IJndiLogger; import org.apache.directory.studio.connection.core.StudioProgressMonitor; import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod; import org.apache.directory.studio.connection.core.Connection.ReferralHandlingMethod; @@ -47,6 +49,9 @@ private final Connection connection; private NamingEnumeration delegate; + private long requestNum; + private long resultEntryCounter; + private String searchBase; private String filter; private SearchControls searchControls; @@ -73,11 +78,13 @@ */ public StudioNamingEnumeration( Connection connection, NamingEnumeration delegate, String searchBase, String filter, SearchControls searchControls, AliasDereferencingMethod aliasesDereferencingMethod, - ReferralHandlingMethod referralsHandlingMethod, Control[] controls, StudioProgressMonitor monitor, - ReferralsInfo referralsInfo ) + ReferralHandlingMethod referralsHandlingMethod, Control[] controls, long requestNum, + StudioProgressMonitor monitor, ReferralsInfo referralsInfo ) { this.connection = connection; this.delegate = delegate; + this.requestNum = requestNum; + this.resultEntryCounter = 0; this.searchBase = searchBase; this.filter = filter; @@ -104,14 +111,22 @@ */ public boolean hasMore() throws NamingException { + NamingException logResultDoneException = null; + boolean logResultDone = false; + while ( true ) { try { - return delegate != null && delegate.hasMore(); + boolean hasMore = delegate != null && delegate.hasMore(); + logResultDone = !hasMore; + return hasMore; } catch ( PartialResultException pre ) { + logResultDone = true; + logResultDoneException = pre; + // ignore exception if referrals handling method is IGNORE // report exception if referrals handling method is FOLLOW or MANGAGE if ( referralsHandlingMethod == ReferralHandlingMethod.IGNORE ) @@ -125,6 +140,9 @@ } catch ( ReferralException re ) { + logResultDone = true; + logResultDoneException = re; + // ignore exception if referrals handling method is IGNORE // report exception if referrals handling method is MANGAGE // follow referral if referrals handling method is FOLLOW @@ -135,6 +153,7 @@ else if ( referralsHandlingMethod == ReferralHandlingMethod.FOLLOW ) { referralsInfo = JNDIConnectionWrapper.handleReferralException( re, referralsInfo ); + logResultDone = false; UrlAndDn urlAndDn = referralsInfo.getNext(); if ( urlAndDn != null ) { @@ -169,6 +188,22 @@ throw re; } } + catch ( NamingException ne ) + { + logResultDone = true; + logResultDoneException = ne; + throw ne; + } + finally + { + if ( logResultDone ) + { + for ( IJndiLogger logger : ConnectionCorePlugin.getDefault().getJndiLoggers() ) + { + logger.logSearchResultDone( connection, resultEntryCounter, requestNum, logResultDoneException ); + } + } + } } } @@ -178,7 +213,15 @@ */ public boolean hasMoreElements() { - return delegate.hasMoreElements(); + boolean hasMore = delegate.hasMoreElements(); + if ( !hasMore ) + { + for ( IJndiLogger logger : ConnectionCorePlugin.getDefault().getJndiLoggers() ) + { + logger.logSearchResultDone( connection, resultEntryCounter, requestNum, null ); + } + } + return hasMore; } @@ -187,10 +230,27 @@ */ public SearchResult next() throws NamingException { - SearchResult searchResult = delegate.next(); - StudioSearchResult studioSearchResult = new StudioSearchResult( searchResult, getConnection(), - referralsInfo != null ); - return studioSearchResult; + StudioSearchResult studioSearchResult = null; + NamingException namingException = null; + try + { + SearchResult searchResult = delegate.next(); + resultEntryCounter++; + studioSearchResult = new StudioSearchResult( searchResult, getConnection(), referralsInfo != null ); + return studioSearchResult; + } + catch ( NamingException ne ) + { + namingException = ne; + throw ne; + } + finally + { + for ( IJndiLogger logger : ConnectionCorePlugin.getDefault().getJndiLoggers() ) + { + logger.logSearchResultEntry( connection, studioSearchResult, requestNum, namingException ); + } + } } @@ -200,7 +260,14 @@ public SearchResult nextElement() { SearchResult searchResult = delegate.nextElement(); - return new StudioSearchResult( searchResult, getConnection(), referralsInfo != null ); + resultEntryCounter++; + StudioSearchResult studioSearchResult = new StudioSearchResult( searchResult, getConnection(), + referralsInfo != null ); + for ( IJndiLogger logger : ConnectionCorePlugin.getDefault().getJndiLoggers() ) + { + logger.logSearchResultEntry( connection, studioSearchResult, requestNum, null ); + } + return studioSearchResult; } Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java?rev=657537&r1=657536&r2=657537&view=diff ============================================================================== --- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java (original) +++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java Sun May 18 04:12:00 2008 @@ -194,7 +194,7 @@ } else { - throw new IllegalArgumentException( BrowserCoreMessages.model__attribute_does_not_exist ); + throw new IllegalArgumentException( BrowserCoreMessages.model__attribute_does_not_exist + ": " + attributeToDelete ); } } Modified: directory/studio/trunk/ldapbrowser-ui/plugin.xml URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/plugin.xml?rev=657537&r1=657536&r2=657537&view=diff ============================================================================== --- directory/studio/trunk/ldapbrowser-ui/plugin.xml (original) +++ directory/studio/trunk/ldapbrowser-ui/plugin.xml Sun May 18 04:12:00 2008 @@ -82,6 +82,13 @@ icon="resources/icons/browser_modificationlogview.gif" id="org.apache.directory.studio.ldapbrowser.ui.views.modificationlogs.ModificationLogsView" name="Modification Logs"/> + @@ -237,6 +244,13 @@ name="Modification Logs"> + + + Apache Directory Project + * @version $Rev$, $Date$ + */ +public class SearchLogsViewActionProxy extends BrowserActionProxy +{ + + /** + * Creates a new instance of SearchLogsViewActionProxy. + * + * @param viewer the viewer + * @param action the real action + */ + public SearchLogsViewActionProxy( Viewer viewer, BrowserAction action ) + { + super( viewer, action ); + } + +} Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/SearchLogsPreferencePage.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/SearchLogsPreferencePage.java?rev=657537&view=auto ============================================================================== --- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/SearchLogsPreferencePage.java (added) +++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/SearchLogsPreferencePage.java Sun May 18 04:12:00 2008 @@ -0,0 +1,115 @@ +/* + * 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.ui.dialogs.preferences; + + +import org.apache.directory.studio.connection.core.ConnectionCoreConstants; +import org.apache.directory.studio.connection.core.ConnectionCorePlugin; +import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils; +import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + + +/** + * The search logs preference page contains settings of the + * search logs view. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class SearchLogsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage +{ + + private Button enableSearchRequestLogging; + private Button enableSearchResultEntryLogging; + + + /** + * Creates a new instance of SearchResultEditorPreferencePage. + */ + public SearchLogsPreferencePage() + { + super( "Search Logs" ); + super.setPreferenceStore( BrowserUIPlugin.getDefault().getPreferenceStore() ); + super.setDescription( "General settings for the search logs view:" ); + } + + + /** + * {@inheritDoc} + */ + public void init( IWorkbench workbench ) + { + } + + + /** + * {@inheritDoc} + */ + protected Control createContents( Composite parent ) + { + Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 ); + + BaseWidgetUtils.createSpacer( composite, 1 ); + BaseWidgetUtils.createSpacer( composite, 1 ); + enableSearchRequestLogging = BaseWidgetUtils.createCheckbox( composite, "Enable search request logs", 1 ); + enableSearchRequestLogging.setSelection( ConnectionCorePlugin.getDefault().getPluginPreferences().getBoolean( + ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE ) ); + enableSearchResultEntryLogging = BaseWidgetUtils.createCheckbox( composite, "Enable search result entry logs (!)", 1 ); + enableSearchResultEntryLogging.setSelection( ConnectionCorePlugin.getDefault().getPluginPreferences().getBoolean( + ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE ) ); + + applyDialogFont( composite ); + return composite; + } + + + /** + * {@inheritDoc} + */ + public boolean performOk() + { + ConnectionCorePlugin.getDefault().getPluginPreferences().setValue( + ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE, enableSearchRequestLogging.getSelection() ); + ConnectionCorePlugin.getDefault().getPluginPreferences().setValue( + ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE, enableSearchResultEntryLogging.getSelection() ); + return true; + } + + + /** + * {@inheritDoc} + */ + protected void performDefaults() + { + enableSearchRequestLogging.setSelection( ConnectionCorePlugin.getDefault().getPluginPreferences() + .getDefaultBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE ) ); + enableSearchResultEntryLogging.setSelection( ConnectionCorePlugin.getDefault().getPluginPreferences() + .getDefaultBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE ) ); + super.performDefaults(); + } + +} Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/perspective/BrowserPerspective.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/perspective/BrowserPerspective.java?rev=657537&r1=657536&r2=657537&view=diff ============================================================================== --- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/perspective/BrowserPerspective.java (original) +++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/perspective/BrowserPerspective.java Sun May 18 04:12:00 2008 @@ -26,6 +26,7 @@ import org.apache.directory.studio.ldapbrowser.ui.views.browser.BrowserView; import org.apache.directory.studio.ldapbrowser.ui.views.connection.ConnectionView; import org.apache.directory.studio.ldapbrowser.ui.views.modificationlogs.ModificationLogsView; +import org.apache.directory.studio.ldapbrowser.ui.views.searchlogs.SearchLogsView; import org.apache.directory.studio.ldapbrowser.ui.wizards.BatchOperationWizard; import org.apache.directory.studio.ldapbrowser.ui.wizards.NewBookmarkWizard; import org.apache.directory.studio.ldapbrowser.ui.wizards.NewEntryWizard; @@ -89,6 +90,7 @@ layout.addShowViewShortcut( ConnectionView.getId() ); layout.addShowViewShortcut( BrowserView.getId() ); layout.addShowViewShortcut( ModificationLogsView.getId() ); + layout.addShowViewShortcut( SearchLogsView.getId() ); layout.addShowViewShortcut( IPageLayout.ID_OUTLINE ); layout.addShowViewShortcut( "org.eclipse.ui.views.ProgressView" ); } @@ -128,6 +130,7 @@ // Log folder IFolderLayout logFolder = layout.createFolder( "logFolder", IPageLayout.BOTTOM, ( float ) 0.75, editorArea ); logFolder.addView( ModificationLogsView.getId() ); + logFolder.addView( SearchLogsView.getId() ); logFolder.addPlaceholder( "*" ); // non-closable? Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewUniversalListener.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewUniversalListener.java?rev=657537&r1=657536&r2=657537&view=diff ============================================================================== --- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewUniversalListener.java (original) +++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewUniversalListener.java Sun May 18 04:12:00 2008 @@ -27,6 +27,7 @@ import org.apache.directory.studio.connection.ui.widgets.ConnectionUniversalListener; import org.apache.directory.studio.ldapbrowser.ui.views.browser.BrowserView; import org.apache.directory.studio.ldapbrowser.ui.views.modificationlogs.ModificationLogsView; +import org.apache.directory.studio.ldapbrowser.ui.views.searchlogs.SearchLogsView; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ISelectionChangedListener; @@ -123,11 +124,23 @@ catch ( NullPointerException e ) { } - + try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( ModificationLogsView.getId(), - null, IWorkbenchPage.VIEW_VISIBLE ); + null, IWorkbenchPage.VIEW_CREATE ); + } + catch ( PartInitException e ) + { + } + catch ( NullPointerException e ) + { + } + + try + { + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( SearchLogsView.getId(), + null, IWorkbenchPage.VIEW_CREATE ); } catch ( PartInitException e ) { Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OpenModificationLogsPreferencePageAction.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OpenModificationLogsPreferencePageAction.java?rev=657537&r1=657536&r2=657537&view=diff ============================================================================== --- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OpenModificationLogsPreferencePageAction.java (original) +++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OpenModificationLogsPreferencePageAction.java Sun May 18 04:12:00 2008 @@ -38,7 +38,7 @@ { /** - * Creates a new instance of OpenEntryEditorPreferencePageAction. + * Creates a new instance of OpenModificationLogsPreferencePageAction. */ public OpenModificationLogsPreferencePageAction() { Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/ClearAction.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/ClearAction.java?rev=657537&view=auto ============================================================================== --- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/ClearAction.java (added) +++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/ClearAction.java Sun May 18 04:12:00 2008 @@ -0,0 +1,112 @@ +/* + * 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.ui.views.searchlogs; + + +import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; +import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; +import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.resource.ImageDescriptor; + + +/** + * Action to clear the log files. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class ClearAction extends BrowserAction +{ + + /** The search logs view. */ + private SearchLogsView view; + + + /** + * Creates a new instance of ClearAction. + * + * @param view + * the search logs view + */ + public ClearAction( SearchLogsView view ) + { + this.view = view; + } + + + /** + * {@inheritDoc} + */ + public String getCommandId() + { + return null; + } + + + /** + * {@inheritDoc} + */ + public ImageDescriptor getImageDescriptor() + { + return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_CLEAR ); + } + + + /** + * {@inheritDoc} + */ + public String getText() + { + return "Clear"; + } + + + /** + * {@inheritDoc} + */ + public boolean isEnabled() + { + return getInput() != null && ( getInput() instanceof SearchLogsViewInput ); + } + + + /** + * {@inheritDoc} + */ + public void run() + { + if ( MessageDialog.openConfirm( this.getShell(), "Delete", "Delete all log files?" ) ) + { + view.getUniversalListener().clearInput(); + } + + } + + + /** + * {@inheritDoc} + */ + public void dispose() + { + super.dispose(); + } + +} Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchRequestLogsAction.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchRequestLogsAction.java?rev=657537&view=auto ============================================================================== --- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchRequestLogsAction.java (added) +++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchRequestLogsAction.java Sun May 18 04:12:00 2008 @@ -0,0 +1,60 @@ +/* + * 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.ui.views.searchlogs; + + +import org.apache.directory.studio.connection.core.ConnectionCoreConstants; +import org.apache.directory.studio.connection.core.ConnectionCorePlugin; +import org.eclipse.jface.action.Action; + + +/** + * This action is used to toggle the "enable search request logs" preference. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class EnableSearchRequestLogsAction extends Action +{ + + /** + * Creates a new instance of EnableSearchRequestLogsAction. + */ + public EnableSearchRequestLogsAction() + { + super( "Enable Search Request Logs", AS_CHECK_BOX ); + setToolTipText( getText() ); + setEnabled( true ); + setChecked( ConnectionCorePlugin.getDefault().getPluginPreferences().getBoolean( + ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE ) ); + } + + + /** + * {@inheritDoc} + */ + public void run() + { + ConnectionCorePlugin.getDefault().getPluginPreferences().setValue( + ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE, super.isChecked() ); + } + +} Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchResultEntryLogsAction.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchResultEntryLogsAction.java?rev=657537&view=auto ============================================================================== --- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchResultEntryLogsAction.java (added) +++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchResultEntryLogsAction.java Sun May 18 04:12:00 2008 @@ -0,0 +1,60 @@ +/* + * 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.ui.views.searchlogs; + + +import org.apache.directory.studio.connection.core.ConnectionCoreConstants; +import org.apache.directory.studio.connection.core.ConnectionCorePlugin; +import org.eclipse.jface.action.Action; + + +/** + * This action is used to toggle the "enable search result entry logs" preference. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class EnableSearchResultEntryLogsAction extends Action +{ + + /** + * Creates a new instance of EnableSearchResultEntryLogsAction. + */ + public EnableSearchResultEntryLogsAction() + { + super( "Enable Search Result Entry Logs (!)", AS_CHECK_BOX ); + setToolTipText( getText() ); + setEnabled( true ); + setChecked( ConnectionCorePlugin.getDefault().getPluginPreferences().getBoolean( + ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE ) ); + } + + + /** + * {@inheritDoc} + */ + public void run() + { + ConnectionCorePlugin.getDefault().getPluginPreferences().setValue( + ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE, super.isChecked() ); + } + +} Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/NewerAction.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/NewerAction.java?rev=657537&view=auto ============================================================================== --- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/NewerAction.java (added) +++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/NewerAction.java Sun May 18 04:12:00 2008 @@ -0,0 +1,114 @@ +/* + * 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.ui.views.searchlogs; + + +import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; +import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; +import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; +import org.eclipse.jface.resource.ImageDescriptor; + + +/** + * Action to switch to a newer logfile. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class NewerAction extends BrowserAction +{ + + /** The search logs view. */ + private SearchLogsView view; + + + /** + * Creates a new instance of NewerAction. + * + * @param view the search logs view + */ + public NewerAction( SearchLogsView view ) + { + this.view = view; + } + + + /** + * {@inheritDoc} + */ + public void dispose() + { + super.dispose(); + } + + + /** + * {@inheritDoc} + */ + public void run() + { + SearchLogsViewInput oldInput = ( SearchLogsViewInput ) getInput(); + SearchLogsViewInput newInput = new SearchLogsViewInput( oldInput.getConnection(), oldInput.getIndex() - 1 ); + view.getUniversalListener().setInput( newInput ); + view.getUniversalListener().scrollToOldest(); + + // go to top + view.getMainWidget().getSourceViewer().setTopIndex( 0 ); + } + + + /** + * {@inheritDoc} + */ + public String getText() + { + return "Newer"; + } + + + /** + * {@inheritDoc} + */ + public ImageDescriptor getImageDescriptor() + { + return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_NEXT ); + } + + + /** + * {@inheritDoc} + */ + public String getCommandId() + { + return null; + } + + + /** + * {@inheritDoc} + */ + public boolean isEnabled() + { + return getInput() != null && ( getInput() instanceof SearchLogsViewInput ) + && ( ( SearchLogsViewInput ) getInput() ).getIndex() > 0; + } + +} Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/OlderAction.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/OlderAction.java?rev=657537&view=auto ============================================================================== --- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/OlderAction.java (added) +++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/OlderAction.java Sun May 18 04:12:00 2008 @@ -0,0 +1,127 @@ +/* + * 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.ui.views.searchlogs; + + +import java.io.File; + +import org.apache.directory.studio.connection.core.ConnectionCorePlugin; +import org.apache.directory.studio.connection.core.io.jndi.LdifSearchLogger; +import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; +import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; +import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; +import org.eclipse.jface.resource.ImageDescriptor; + + +/** + * Action to switch to an older logfile. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class OlderAction extends BrowserAction +{ + + /** The search logs view. */ + private SearchLogsView view; + + + /** + * Creates a new instance of OlderAction. + * + * @param view the search logs view + */ + public OlderAction( SearchLogsView view ) + { + this.view = view; + } + + + /** + * {@inheritDoc} + */ + public void dispose() + { + super.dispose(); + } + + + /** + * {@inheritDoc} + */ + public void run() + { + SearchLogsViewInput oldInput = ( SearchLogsViewInput ) getInput(); + SearchLogsViewInput newInput = new SearchLogsViewInput( oldInput.getConnection(), oldInput + .getIndex() + 1 ); + view.getUniversalListener().setInput( newInput ); + view.getUniversalListener().scrollToNewest(); + } + + + /** + * {@inheritDoc} + */ + public String getText() + { + return "Older"; + } + + + /** + * {@inheritDoc} + */ + public ImageDescriptor getImageDescriptor() + { + return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_PREVIOUS ); + } + + + /** + * {@inheritDoc} + */ + public String getCommandId() + { + return null; + } + + + /** + * {@inheritDoc} + */ + public boolean isEnabled() + { + if ( getInput() != null && ( getInput() instanceof SearchLogsViewInput ) ) + { + SearchLogsViewInput input = ( SearchLogsViewInput ) getInput(); + LdifSearchLogger searchLogger = ConnectionCorePlugin.getDefault().getLdifSearchLogger(); + File[] files = searchLogger.getFiles( input.getConnection().getConnection() ); + int i = input.getIndex() + 1; + if ( 0 <= i && i < files.length && files[i] != null && files[i].exists() && files[i].canRead() ) + { + return true; + } + } + + return false; + } + +} Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/OpenSearchLogsPreferencePageAction.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/OpenSearchLogsPreferencePageAction.java?rev=657537&view=auto ============================================================================== --- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/OpenSearchLogsPreferencePageAction.java (added) +++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/OpenSearchLogsPreferencePageAction.java Sun May 18 04:12:00 2008 @@ -0,0 +1,62 @@ +/* + * 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.ui.views.searchlogs; + + +import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; +import org.eclipse.jface.action.Action; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.dialogs.PreferencesUtil; + + +/** + * This action opens the prefence page of the search logs view. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class OpenSearchLogsPreferencePageAction extends Action +{ + + /** + * Creates a new instance of OpenSearchLogsPreferencePageAction. + */ + public OpenSearchLogsPreferencePageAction() + { + setText( "Preferences..." ); + setToolTipText( "Preferences..." ); + setEnabled( true ); + } + + + /** + * {@inheritDoc} + */ + public void run() + { + Shell shell = Display.getCurrent().getActiveShell(); + String mlPageId = BrowserUIConstants.PREFERENCEPAGEID_SEARCHLOGS; + PreferencesUtil.createPreferenceDialogOn( shell, mlPageId, new String[] + { mlPageId }, null ).open(); + } + +} Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/RefreshAction.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/RefreshAction.java?rev=657537&view=auto ============================================================================== --- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/RefreshAction.java (added) +++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/RefreshAction.java Sun May 18 04:12:00 2008 @@ -0,0 +1,110 @@ +/* + * 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.ui.views.searchlogs; + + +import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; +import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; +import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; +import org.eclipse.jface.resource.ImageDescriptor; + + +/** + * Action to refresh the view from logfile. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class RefreshAction extends BrowserAction +{ + + /** The search logs view. */ + private SearchLogsView view; + + + /** + * Creates a new instance of RefreshAction. + * + * @param view the search logs view + */ + public RefreshAction( SearchLogsView view ) + { + this.view = view; + } + + + /** + * {@inheritDoc} + */ + public void dispose() + { + super.dispose(); + } + + + /** + * {@inheritDoc} + */ + public void run() + { + // int topIndex = view.getMainWidget().getSourceViewer().getTopIndex(); + view.getUniversalListener().refreshInput(); + view.getUniversalListener().scrollToNewest(); + // view.getMainWidget().getSourceViewer().setTopIndex(topIndex); + } + + + /** + * {@inheritDoc} + */ + public String getText() + { + return "Refresh"; + } + + + /** + * {@inheritDoc} + */ + public ImageDescriptor getImageDescriptor() + { + return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_REFRESH ); + } + + + /** + * {@inheritDoc} + */ + public String getCommandId() + { + return null; + } + + + /** + * {@inheritDoc} + */ + public boolean isEnabled() + { + return getInput() != null && ( getInput() instanceof SearchLogsViewInput ); + } + +} Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsView.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsView.java?rev=657537&view=auto ============================================================================== --- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsView.java (added) +++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsView.java Sun May 18 04:12:00 2008 @@ -0,0 +1,164 @@ +/* + * 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.ui.views.searchlogs; + + +import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; +import org.apache.directory.studio.ldifeditor.widgets.LdifEditorWidget; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.ViewPart; + + +/** + * The SearchLogsView displays all searched performed + * to a connection using LDIF format. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class SearchLogsView extends ViewPart +{ + + /** The action group. */ + private SearchLogsViewActionGroup actionGroup; + + /** The main widget. */ + private LdifEditorWidget mainWidget; + + /** The universal listener. */ + private SearchLogsViewUniversalListener universalListener; + + + /** + * Gets the id. + * + * @return the id + */ + public static String getId() + { + return SearchLogsView.class.getName(); + } + + + /** + * Creates a new instance of ModificationLogsView. + */ + public SearchLogsView() + { + super(); + } + + + /** + * {@inheritDoc} + */ + public void setFocus() + { + mainWidget.getSourceViewer().getTextWidget().setFocus(); + } + + + /** + * {@inheritDoc} + */ + public void dispose() + { + if ( mainWidget != null ) + { + actionGroup.dispose(); + actionGroup = null; + universalListener.dispose(); + universalListener = null; + mainWidget.dispose(); + mainWidget = null; + } + super.dispose(); + } + + + /** + * {@inheritDoc} + */ + public void createPartControl( Composite parent ) + { + Composite composite = new Composite( parent, SWT.NONE ); + composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); + GridLayout layout = new GridLayout(); + layout.marginWidth = 0; + layout.marginHeight = 0; + composite.setLayout( layout ); + + // create main widget + mainWidget = new LdifEditorWidget( null, "", false ); + mainWidget.createWidget( composite ); + mainWidget.getSourceViewer().setEditable( false ); + + // create actions and context menu (and register global actions) + actionGroup = new SearchLogsViewActionGroup( this ); + actionGroup.fillActionBars( getViewSite().getActionBars() ); + // this.actionGroup.fillContextMenu(this.configuration.getContextMenuManager(this.mainWidget.getViewer())); + + // create the listener + universalListener = new SearchLogsViewUniversalListener( this ); + + // set help context + PlatformUI.getWorkbench().getHelpSystem().setHelp( mainWidget.getSourceViewer().getTextWidget(), + BrowserUIPlugin.PLUGIN_ID + "." + "tools_modification_logs_view" ); + } + + + /** + * Gets the main widget. + * + * @return the main widget + */ + public LdifEditorWidget getMainWidget() + { + return mainWidget; + } + + + /** + * Gets the universal listener. + * + * @return the universal listener + */ + public SearchLogsViewUniversalListener getUniversalListener() + { + return universalListener; + } + + + /** + * Gets the action group. + * + * @return the action group + */ + public SearchLogsViewActionGroup getActionGroup() + { + return actionGroup; + } + +}