directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1813579 - /directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/
Date Fri, 27 Oct 2017 22:15:16 GMT
Author: elecharny
Date: Fri Oct 27 22:15:15 2017
New Revision: 1813579

URL: http://svn.apache.org/viewvc?rev=1813579&view=rev
Log:
Applied patch for DIRSTUDIO-1156.

Modified:
    directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java
    directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/TextDialog.java
    directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages.properties
    directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_de.properties
    directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_fr.properties

Modified: directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java?rev=1813579&r1=1813578&r2=1813579&view=diff
==============================================================================
--- directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java
(original)
+++ directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java
Fri Oct 27 22:15:15 2017
@@ -23,11 +23,9 @@ package org.apache.directory.studio.ldap
 
 import java.io.File;
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.nio.charset.StandardCharsets;
 
 import org.apache.directory.api.util.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;
@@ -101,21 +99,12 @@ public class HexDialog extends Dialog
         }
         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, StandardCharsets.UTF_8
) );
+            if ( dialog.open() == TextDialog.OK )
             {
-                TextDialog dialog = new TextDialog( getShell(), new String( currentData,
StandardCharsets.UTF_8 ) );
-
-                if ( dialog.open() == TextDialog.OK )
-                {
-                    String text = dialog.getText();
-                    currentData = text.getBytes( StandardCharsets.UTF_8 );
-                    hexText.setText( toFormattedHex( currentData ) );
-                }
-            }
-            else
-            {
-                CommonUIUtils.openErrorDialog( Messages.getString( "HexDialog.NonTextEditable"
) ); //$NON-NLS-1$
+                String text = dialog.getText();
+                currentData = text.getBytes( StandardCharsets.UTF_8 );
+                hexText.setText( toFormattedHex( currentData ) );
             }
         }
         else if ( buttonId == SAVE_BUTTON_ID )
@@ -198,7 +187,11 @@ 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$
+        if ( isEditable( currentData ) )
+        {
+           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 );
@@ -218,10 +211,8 @@ public class HexDialog extends Dialog
         hexText.setFont( JFaceResources.getFont( JFaceResources.TEXT_FONT ) );
 
         hexText.setText( toFormattedHex( currentData ) );
-        // GridData gd = new GridData(GridData.GRAB_HORIZONTAL |
-        // GridData.HORIZONTAL_ALIGN_FILL);
         GridData gd = new GridData( GridData.FILL_BOTH );
-        gd.widthHint = convertHorizontalDLUsToPixels( ( int ) ( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH
* 1.6 ) );
+        gd.widthHint = convertHorizontalDLUsToPixels( ( int ) ( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH
* 1.4 ) );
         gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH
/ 2 );
         hexText.setLayoutData( gd );
 
@@ -231,8 +222,8 @@ public class HexDialog extends Dialog
 
 
     /**
-     * Formats the binary data in two colums. One containing the hex
-     * presentation and one containting the ASCII presentation of each byte.
+     * Formats the binary data in two columns. One containing the hex
+     * presentation and one containing the ASCII presentation of each byte.
      * 
      * 91 a1 08 23 42 b1 c1 15  52 d1 f0 24 33 62 72 82     ...#B... R..$3br.
      * 09 0a 16 17 18 19 1a 25  26 27 28 29 2a 34 35 36     .......% &'()*456 

Modified: directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/TextDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/TextDialog.java?rev=1813579&r1=1813578&r2=1813579&view=diff
==============================================================================
--- directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/TextDialog.java
(original)
+++ directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/TextDialog.java
Fri Oct 27 22:15:15 2017
@@ -21,12 +21,18 @@
 package org.apache.directory.studio.ldapbrowser.common.dialogs;
 
 
+import java.util.HashMap;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Shell;
@@ -48,9 +54,22 @@ public class TextDialog extends Dialog
 
     /** The return value. */
     private String returnValue;
+    
+    /** The button ID for the save button. */
+    private static final int TOGGLE_BUTTON_ID = 9999;
+    
+    /**
+     * Collection of buttons created by the <code>createButton</code> method.
+     */
+   private HashMap<Integer, Button> buttons = new HashMap<>();
 
     /** The text area. */
     private Text text;
+    
+    private int defaultTextStyle = SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL;
+   
+    /** The check box to enable line wrap */
+    GridData gd = new GridData();
 
 
     /**
@@ -62,11 +81,55 @@ public class TextDialog extends Dialog
     public TextDialog( Shell parentShell, String initialValue )
     {
         super( parentShell );
-        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE | SWT.MAX );
         this.initialValue = initialValue;
         this.returnValue = null;
     }
 
+    
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#createButton(org.eclipse.swt.widgets.Composite,
int, String, boolean)
+     */
+    @Override
+   protected Button createButton( Composite parent, int id, String label, boolean defaultButton
) 
+    {
+       return createButton( parent, id, label, defaultButton, SWT.PUSH );
+   }
+       
+   protected Button createButton( Composite parent, int id, String label, boolean defaultButton,
int style ) 
+   {
+       // increment the number of columns in the button bar
+       ( ( GridLayout ) parent.getLayout() ).numColumns++;
+       Button button = new Button( parent, style );
+       button.setText( label );
+       button.setFont( JFaceResources.getDialogFont() );
+       button.setData( Integer.valueOf( id ) );
+       button.addSelectionListener( 
+           new SelectionAdapter() 
+           {
+               @Override
+               public void widgetSelected( SelectionEvent event ) 
+               {
+                   buttonPressed( ( ( Integer ) event.widget.getData() ).intValue() );
+               }
+           });
+       
+       if ( defaultButton ) 
+       {
+           Shell shell = parent.getShell();
+           
+           if ( shell != null ) 
+           {
+               shell.setDefaultButton( button );
+           }
+       }
+       
+       buttons.put( Integer.valueOf( id ), button );
+       setButtonLayoutData( button );
+       
+       return button;
+   }
+
 
     /**
      * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
@@ -86,9 +149,38 @@ public class TextDialog extends Dialog
     @Override
     protected void createButtonsForButtonBar( Composite parent )
     {
+        createButton( parent, TOGGLE_BUTTON_ID, Messages.getString( "TextDialog.WrapLines"
), false, SWT.TOGGLE ); //$NON-NLS-1$
         createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
         createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL,
false );
     }
+    
+    
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+     */
+    protected void buttonPressed( int buttonId )
+    {
+       if ( TOGGLE_BUTTON_ID == buttonId ) 
+       {
+           String currentValue = text.getText();
+           Composite composite = text.getParent();
+           text.dispose();
+           createText(composite, currentValue, getButton( TOGGLE_BUTTON_ID ).getSelection()
);
+           text.requestLayout();   
+        }
+       
+        super.buttonPressed( buttonId );
+    }
+    
+    
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#getButton()
+     */
+    @Override
+    protected Button getButton( int id ) 
+    {
+       return buttons.get( Integer.valueOf( id ) );
+   }
 
 
     /**
@@ -110,23 +202,34 @@ public class TextDialog extends Dialog
     {
         // create composite
         Composite composite = ( Composite ) super.createDialogArea( parent );
-        GridData gd = new GridData( GridData.FILL_BOTH );
-        composite.setLayoutData( gd );
-
+        
+        composite.setLayoutData( new GridData( SWT.FILL,SWT.FILL,true,true ) );
+        
         // text widget
-        text = new Text( composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
);
-        text.setText( this.initialValue );
-        // GridData gd = new GridData(GridData.GRAB_HORIZONTAL |
-        // GridData.HORIZONTAL_ALIGN_FILL);
-        gd = new GridData( GridData.FILL_BOTH );
-        gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH
);
-        gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH
/ 2 );
-        text.setLayoutData( gd );
-
-        applyDialogFont( composite );
+        createText( composite, this.initialValue, false );
         
         return composite;
     }
+    
+    
+     protected void createText( Composite composite, String value, boolean wrap ) 
+     {
+         if ( wrap ) 
+         {
+             text = new Text( composite, defaultTextStyle | SWT.WRAP);
+         } 
+         else 
+         {
+             text = new Text( composite, defaultTextStyle );
+         }
+        
+         text.setText( value );
+         gd = new GridData( SWT.FILL,SWT.FILL,true,true );
+         gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH
* 2);
+         gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
+         text.setLayoutData( gd );
+         applyDialogFont( composite );
+    }
 
 
     /**

Modified: directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages.properties?rev=1813579&r1=1813578&r2=1813579&view=diff
==============================================================================
--- directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages.properties
(original)
+++ directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages.properties
Fri Oct 27 22:15:15 2017
@@ -30,7 +30,6 @@ 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
@@ -50,3 +49,4 @@ SimulateRenameDialogImpl.SimulateRename=
 SimulateRenameDialogImpl.SimulateRenameDescription1=You are trying to move/rename {0} to
{1}.
 SimulateRenameDialogImpl.SimulateRenameDescription2=The LDAP server {0} doesn't support moving/renaming
of non-leaf entries.
 TextDialog.TextEditor=Text Editor
+TextDialog.WrapLines=Wrap lines
\ No newline at end of file

Modified: directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_de.properties?rev=1813579&r1=1813578&r2=1813579&view=diff
==============================================================================
--- directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_de.properties
(original)
+++ directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_de.properties
Fri Oct 27 22:15:15 2017
@@ -30,7 +30,6 @@ 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
@@ -50,3 +49,4 @@ SimulateRenameDialogImpl.SimulateRename=
 SimulateRenameDialogImpl.SimulateRenameDescription1=Sie versuchen {0} nach {1} umzubenennen
bzw. zu verschieben.
 SimulateRenameDialogImpl.SimulateRenameDescription2=Der LDAP Server {0} unterst\u00FCtzt
nicht das Umbenennen bzw. Verschieben von Container-Eintr\u00E4gen.
 TextDialog.TextEditor=Text Editor
+TextDialog.WrapLines=Zeilenumbruch
\ No newline at end of file

Modified: directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_fr.properties?rev=1813579&r1=1813578&r2=1813579&view=diff
==============================================================================
--- directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_fr.properties
(original)
+++ directory/studio/branches/studio-value/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/messages_fr.properties
Fri Oct 27 22:15:15 2017
@@ -30,7 +30,6 @@ 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\u00E8res ne pouvant \u00EAtre affich\u00E9s
et ne peut \u00EAtre \u00E9dit\u00E9e comme texte.
 HexDialog.SaveData=Sauvegarder des donn\u00E9es
 HexDialog.SaveDataButton=Sauvegarder des donn\u00E9es...
 MoveEntriesDialog.MoveEntries=D\u00E9placer les entr\u00E9es
@@ -50,3 +49,4 @@ SimulateRenameDialogImpl.SimulateRename=
 SimulateRenameDialogImpl.SimulateRenameDescription1=Vous essayez de d\u00E9placer/renommer
{0} vers/en {1}.
 SimulateRenameDialogImpl.SimulateRenameDescription2=Le serveur LDAP {0} ne supporte pas le
d\u00E9placement/renommage d''entr\u00E9e qui ne sont pas des feuilles.
 TextDialog.TextEditor=Editeur de texte
+TextDialog.WrapLines=Formatage des lignes
\ No newline at end of file



Mime
View raw message