directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ckopp...@apache.org
Subject svn commit: r544004 - in /directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui: ./ views/modificationlogs/
Date Sun, 03 Jun 2007 22:35:07 GMT
Author: ckoppelt
Date: Sun Jun  3 15:35:05 2007
New Revision: 544004

URL: http://svn.apache.org/viewvc?view=rev&rev=544004
Log:
fix for DIRSTUDIO-67

Added:
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ClearAction.java
Modified:
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/BrowserUIConstants.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/BrowserUIConstants.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/BrowserUIConstants.java?view=diff&rev=544004&r1=544003&r2=544004
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/BrowserUIConstants.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/BrowserUIConstants.java
Sun Jun  3 15:35:05 2007
@@ -230,5 +230,7 @@
     public static final String IMG_PREVIOUS = "resources/icons/previous.gif";
 
     public static final String IMG_REFRESH = "resources/icons/refresh.gif";
+    
+    public static final String IMG_CLEAR = "resources/icons/delete.gif";
 
 }

Added: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ClearAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ClearAction.java?view=auto&rev=544004
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ClearAction.java
(added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ClearAction.java
Sun Jun  3 15:35:05 2007
@@ -0,0 +1,106 @@
+/*
+ *  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.ldapstudio.browser.ui.views.modificationlogs;
+
+
+import org.apache.directory.ldapstudio.browser.common.actions.BrowserAction;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+public class ClearAction extends BrowserAction
+{
+
+    /** The modification logs view. */
+    private ModificationLogsView view;
+
+
+    /**
+     * Creates a new instance of ClearAction.
+     * 
+     * @param view
+     *            the modification logs view
+     */
+    public ClearAction( ModificationLogsView 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 ModificationLogsViewInput
);
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        if ( MessageDialog.openConfirm( this.getShell(), "Delete", "Delete all log files?"
) )
+        {
+            view.getUniversalListener().clearInput();
+        }
+
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        super.dispose();
+    }
+
+}

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java?view=diff&rev=544004&r1=544003&r2=544004
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java
Sun Jun  3 15:35:05 2007
@@ -54,6 +54,9 @@
 
     /** The Constant refreshAction. */
     private static final String refreshAction = "refreshAction";
+    
+    /** The Constant refreshAction. */
+    private static final String clearAction = "clearAction";
 
     /** The modification logs view action map. */
     private Map<String, ModificationLogsViewActionProxy> modificationLogsViewActionMap;
@@ -76,6 +79,8 @@
             view ) ) );
         modificationLogsViewActionMap.put( refreshAction, new ModificationLogsViewActionProxy(
viewer,
             new RefreshAction( view ) ) );
+        modificationLogsViewActionMap.put( clearAction, new ModificationLogsViewActionProxy(
viewer, new ClearAction(
+            view ) ) );
     }
 
 
@@ -111,6 +116,7 @@
     public void fillActionBars( IActionBars actionBars )
     {
         // Tool Bar
+    	actionBars.getToolBarManager().add( ( IAction ) modificationLogsViewActionMap.get( clearAction
) );
         actionBars.getToolBarManager().add( ( IAction ) modificationLogsViewActionMap.get(
refreshAction ) );
         actionBars.getToolBarManager().add( new Separator() );
         actionBars.getToolBarManager().add( ( IAction ) modificationLogsViewActionMap.get(
olderAction ) );

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java?view=diff&rev=544004&r1=544003&r2=544004
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java
Sun Jun  3 15:35:05 2007
@@ -23,6 +23,7 @@
 
 import java.io.File;
 import java.io.FileReader;
+import java.io.FileWriter;
 
 import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator;
 import org.apache.directory.ldapstudio.browser.common.actions.SelectionUtils;
@@ -206,6 +207,36 @@
         {
         }
 
+    }
+    
+	/**
+     * Clears the input and deletes the logfiles for it
+     * 
+     */
+    public void clearInput()
+    {
+        StringBuffer sb = new StringBuffer( "" );
+        FileWriter fw = null;
+        File[] files = input.getConnection().getModificationLogger().getFiles();
+        input.getConnection().getModificationLogger().dispose();
+        for ( int i = 0; i < files.length; i++ )
+        {
+            try
+            {
+                if ( files[i] != null && files[i].exists() && !files[i].delete()
)
+                {
+                    fw = new FileWriter( files[i] );
+                    fw.write( "" );
+                }
+
+            }
+            catch ( Exception e )
+            {
+                sb.append( e.getMessage() );
+            }
+        }
+        view.getMainWidget().getSourceViewer().setTopIndex( 0 );
+        view.getMainWidget().getSourceViewer().getDocument().set( sb.toString() );
     }
 
 }



Mime
View raw message