directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1496058 - in /directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio: ldapbrowser/common/dialogs/ valueeditors/
Date Mon, 24 Jun 2013 13:59:04 GMT
Author: pamarcelot
Date: Mon Jun 24 13:59:03 2013
New Revision: 1496058

URL: http://svn.apache.org/r1496058
Log:
Fix for DIRSTUDIO-929 (Improve Hex Value Editor to allow text edition).
+ a small increment on the amount of data displayed in raw format for binary attributes.

Modified:
    directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java
    directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages.properties
    directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_de.properties
    directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_fr.properties
    directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/valueeditors/AbstractDialogBinaryValueEditor.java

Modified: directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java?rev=1496058&r1=1496057&r2=1496058&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java
Mon Jun 24 13:59:03 2013
@@ -23,8 +23,10 @@ package org.apache.directory.studio.ldap
 
 import java.io.File;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.directory.studio.common.ui.CommonUIUtils;
 import org.apache.directory.studio.connection.ui.ConnectionUIPlugin;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
@@ -54,6 +56,9 @@ public class HexDialog extends Dialog
     /** The default title. */
     private static final String DIALOG_TITLE = Messages.getString( "HexDialog.HexEditor"
); //$NON-NLS-1$
 
+    /** The button ID for the edit as text button. */
+    private static final int EDIT_AS_TEXT_BUTTON_ID = 9997;
+
     /** The button ID for the load button. */
     private static final int LOAD_BUTTON_ID = 9998;
 
@@ -93,11 +98,29 @@ public class HexDialog extends Dialog
         {
             returnData = currentData;
         }
+        else if ( buttonId == EDIT_AS_TEXT_BUTTON_ID )
+        {
+            // Checking if the data is "text-editable"
+            if ( isEditable( currentData ) )
+            {
+                TextDialog dialog = new TextDialog( getShell(), new String( currentData )
);
+
+                if ( dialog.open() == TextDialog.OK )
+                {
+                    String text = dialog.getText();
+                    currentData = text.getBytes();
+                    hexText.setText( toFormattedHex( currentData ) );
+                }
+            }
+            else
+            {
+                CommonUIUtils.openErrorDialog( Messages.getString( "HexDialog.NonTextEditable"
) ); //$NON-NLS-1$
+            }
+        }
         else if ( buttonId == SAVE_BUTTON_ID )
         {
             FileDialog fileDialog = new FileDialog( getShell(), SWT.SAVE );
             fileDialog.setText( Messages.getString( "HexDialog.SaveData" ) ); //$NON-NLS-1$
-            // fileDialog.setFilterExtensions(new String[]{"*.jpg"});
             String returnedFileName = fileDialog.open();
             if ( returnedFileName != null )
             {
@@ -145,6 +168,27 @@ public class HexDialog extends Dialog
 
 
     /**
+     * Small helper.
+     */
+    private boolean isEditable( byte[] b )
+    {
+        if ( b == null )
+        {
+            return false;
+        }
+
+        try
+        {
+            return !( new String( b, "UTF-8" ).contains( "\uFFFD" ) );
+        }
+        catch ( UnsupportedEncodingException e )
+        {
+            return false;
+        }
+    }
+
+
+    /**
      * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
      */
     protected void configureShell( Shell shell )
@@ -160,6 +204,7 @@ public class HexDialog extends Dialog
      */
     protected void createButtonsForButtonBar( Composite parent )
     {
+        createButton( parent, EDIT_AS_TEXT_BUTTON_ID, Messages.getString( "HexDialog.EditAsText"
), false ); //$NON-NLS-1$
         createButton( parent, LOAD_BUTTON_ID, Messages.getString( "HexDialog.LoadDataButton"
), false ); //$NON-NLS-1$
         createButton( parent, SAVE_BUTTON_ID, Messages.getString( "HexDialog.SaveDataButton"
), false ); //$NON-NLS-1$
         createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
@@ -289,5 +334,4 @@ public class HexDialog extends Dialog
     {
         return returnData;
     }
-
 }

Modified: directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages.properties?rev=1496058&r1=1496057&r2=1496058&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages.properties
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages.properties
Mon Jun 24 13:59:03 2013
@@ -26,9 +26,11 @@ FilterDialog.Format=Format
 FilterWidgetDialog.EnterValidFilter=Please enter a valid filter.
 HexDialog.CantReadFile=Can't read file
 HexDialog.CantWriteToFile=Can't write to file
+HexDialog.EditAsText=Edit as Text...
 HexDialog.HexEditor=Hex Editor
 HexDialog.LoadData=Load Data
 HexDialog.LoadDataButton=Load Data...
+HexDialog.NonTextEditable=The value contains non-printable characters and can not be edited
as text.
 HexDialog.SaveData=Save Data
 HexDialog.SaveDataButton=Save Data...
 MoveEntriesDialog.MoveEntries=Move Entries

Modified: directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_de.properties?rev=1496058&r1=1496057&r2=1496058&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_de.properties
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_de.properties
Mon Jun 24 13:59:03 2013
@@ -26,9 +26,11 @@ FilterDialog.Format=Formatieren
 FilterWidgetDialog.EnterValidFilter=Bitte g\u00FCltigen Filter eingeben.
 HexDialog.CantReadFile=Datei kann nicht gelesen werden
 HexDialog.CantWriteToFile=Datei kann nicht geschrieben werden
+HexDialog.EditAsText=Als Text bearbeiten...
 HexDialog.HexEditor=Hex Editor
 HexDialog.LoadData=Daten laden
 HexDialog.LoadDataButton=Daten laden...
+HexDialog.NonTextEditable=Der Wert enthält nicht-druckbare Zeichen und kann nicht als Text
bearbeitet werden.
 HexDialog.SaveData=Daten speichern
 HexDialog.SaveDataButton=Daten speichern...
 MoveEntriesDialog.MoveEntries=Eintr\u00E4ge verschieben

Modified: directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_fr.properties?rev=1496058&r1=1496057&r2=1496058&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_fr.properties
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_fr.properties
Mon Jun 24 13:59:03 2013
@@ -26,9 +26,11 @@ FilterDialog.Format=Formater
 FilterWidgetDialog.EnterValidFilter=Veuillez entrer un filtre valide.
 HexDialog.CantReadFile=Impossible de lire le fichier
 HexDialog.CantWriteToFile=Impossible d'\u00E9crire le fichier
+HexDialog.EditAsText=Editer comme texte...
 HexDialog.HexEditor=Editeur Hex
 HexDialog.LoadData=Charger des donn\u00E9es
 HexDialog.LoadDataButton=Charger des donn\u00E9es...
+HexDialog.NonTextEditable=La valeur contient des caractères ne pouvant être affichés et
ne peut être éditée comme texte.
 HexDialog.SaveData=Sauvegarder des donn\u00E9es
 HexDialog.SaveDataButton=Sauvegarder des donn\u00E9es...
 MoveEntriesDialog.MoveEntries=D\u00E9placer les entr\u00E9es

Modified: directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/valueeditors/AbstractDialogBinaryValueEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/valueeditors/AbstractDialogBinaryValueEditor.java?rev=1496058&r1=1496057&r2=1496058&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/valueeditors/AbstractDialogBinaryValueEditor.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/valueeditors/AbstractDialogBinaryValueEditor.java
Mon Jun 24 13:59:03 2013
@@ -93,7 +93,7 @@ public abstract class AbstractDialogBina
         {
             byte[] data = value.getBinaryValue();
             StringBuffer sb = new StringBuffer();
-            for ( int i = 0; data != null && i < data.length && i <
128; i++ )
+            for ( int i = 0; data != null && i < data.length && i <
512; i++ )
             {
                 if ( data[i] > 32 && data[i] < 127 )
                     sb.append( ( char ) data[i] );



Mime
View raw message