Author: seelmann Date: Thu Mar 1 14:30:01 2007 New Revision: 513539 URL: http://svn.apache.org/viewvc?view=rev&rev=513539 Log: Code cleaning and Javadoc Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/PasswordDialog.java directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/BaseWidgetUtils.java directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/BinaryEncodingInput.java directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/BrowserWidget.java directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/DialogContentAssistant.java directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/DnBuilderWidget.java directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/FileBrowserWidget.java directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/FileEncodingInput.java directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/HistoryUtils.java directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/LineSeparatorInput.java directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/OptionsInput.java directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserCategory.java directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserSearchResultPage.java Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/PasswordDialog.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/PasswordDialog.java?view=diff&rev=513539&r1=513538&r2=513539 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/PasswordDialog.java (original) +++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/PasswordDialog.java Thu Mar 1 14:30:01 2007 @@ -27,11 +27,11 @@ import org.apache.directory.ldapstudio.browser.core.model.IConnection; import org.apache.directory.ldapstudio.browser.core.model.IEntry; import org.apache.directory.ldapstudio.browser.core.model.Password; +import org.apache.directory.ldapstudio.browser.core.utils.Utils; import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants; import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin; import org.apache.directory.ldapstudio.browser.ui.jobs.RunnableContextJobAdapter; import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils; - import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; @@ -356,11 +356,11 @@ { if ( this.currentPassword != null ) { - this.currentPasswordHashMethodText.setText( BaseWidgetUtils.getNonNullString( this.currentPassword + this.currentPasswordHashMethodText.setText( Utils.getNonNullString( this.currentPassword .getHashMethod() ) ); - this.currentPasswordValueHexText.setText( BaseWidgetUtils.getNonNullString( this.currentPassword + this.currentPasswordValueHexText.setText( Utils.getNonNullString( this.currentPassword .getHashedPasswordAsHexString() ) ); - this.currentPasswordSaltHexText.setText( BaseWidgetUtils.getNonNullString( this.currentPassword + this.currentPasswordSaltHexText.setText( Utils.getNonNullString( this.currentPassword .getSaltAsHexString() ) ); this.currentPasswordText.setText( this.currentPassword.toString() ); } @@ -432,9 +432,9 @@ this.newPassword = new Password( this.newPasswordHashMethodCombo.getText(), this.newPasswordText.getText() ); if ( !"".equals( this.newPasswordText.getText() ) || this.newPassword.getHashMethod() == null ) { - newPasswordPreviewValueHexText.setText( BaseWidgetUtils.getNonNullString( this.newPassword + newPasswordPreviewValueHexText.setText( Utils.getNonNullString( this.newPassword .getHashedPasswordAsHexString() ) ); - newPasswordPreviewSaltHexText.setText( BaseWidgetUtils.getNonNullString( this.newPassword + newPasswordPreviewSaltHexText.setText( Utils.getNonNullString( this.newPassword .getSaltAsHexString() ) ); newPasswordPreviewText.setText( this.newPassword.toString() ); newSaltButton.setEnabled( this.newPassword.getSalt() != null ); @@ -444,9 +444,9 @@ else { this.newPassword = null; - newPasswordPreviewValueHexText.setText( BaseWidgetUtils.getNonNullString( null ) ); - newPasswordPreviewSaltHexText.setText( BaseWidgetUtils.getNonNullString( null ) ); - newPasswordPreviewText.setText( BaseWidgetUtils.getNonNullString( null ) ); + newPasswordPreviewValueHexText.setText( Utils.getNonNullString( null ) ); + newPasswordPreviewSaltHexText.setText( Utils.getNonNullString( null ) ); + newPasswordPreviewText.setText( Utils.getNonNullString( null ) ); newSaltButton.setEnabled( false ); this.okButton.setEnabled( false ); } Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/BaseWidgetUtils.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/BaseWidgetUtils.java?view=diff&rev=513539&r1=513538&r2=513539 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/BaseWidgetUtils.java (original) +++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/BaseWidgetUtils.java Thu Mar 1 14:30:01 2007 @@ -38,9 +38,23 @@ import org.eclipse.swt.widgets.Text; +/** + * This class provides utility methods to create SWT widgets. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ public class BaseWidgetUtils { + /** + * Creates a SWT {@link Group} under the given parent. + * + * @param parent the parent + * @param label the label of the group + * @param span the horizontal span + * @return the created group + */ public static Group createGroup( Composite parent, String label, int span ) { Group group = new Group( parent, SWT.NONE ); @@ -53,6 +67,15 @@ } + /** + * Creates a SWT {@link Composite} under the given parent. + * A GridLayout with the given number of columns is used. + * + * @param parent the parent + * @param columnCount the number of columns + * @param span the horizontal span + * @return the created composite + */ public static Composite createColumnContainer( Composite parent, int columnCount, int span ) { Composite container = new Composite( parent, SWT.NONE ); @@ -66,6 +89,14 @@ } + /** + * Creates a SWT {@link Label} under the given parent. + * + * @param parent the parent + * @param text the label's text + * @param span the horizontal span + * @return the created label + */ public static Label createLabel( Composite parent, String text, int span ) { Label l = new Label( parent, SWT.NONE ); @@ -78,6 +109,15 @@ } + /** + * Creates a SWT {@link Label} under the given parent. + * The label is created with the SWT.WRAP style to enable line wrapping. + * + * @param parent the parent + * @param text the label's text + * @param span the horizontal span + * @return the created label + */ public static Label createWrappedLabel( Composite parent, String text, int span ) { Label l = new Label( parent, SWT.WRAP ); @@ -90,6 +130,15 @@ } + /** + * Creates a SWT {@link Text} under the given parent. + * The created text control is modifyable. + * + * @param parent the parent + * @param text the initial text + * @param span the horizontal span + * @return the created text + */ public static Text createText( Composite parent, String text, int span ) { Text t = new Text( parent, SWT.NONE | SWT.BORDER ); @@ -101,6 +150,16 @@ } + /** + * Creates a SWT {@link Text} under the given parent. + * The created text control is modifyable. + * + * @param parent the parent + * @param text the initial text + * @param textWidth the width of the text control + * @param span the horizontal span + * @return the created text + */ public static Text createText( Composite parent, String text, int textWidth, int span ) { Text t = new Text( parent, SWT.NONE | SWT.BORDER ); @@ -114,6 +173,15 @@ } + /** + * Creates a SWT {@link Text} under the given parent. + * The created text control is created with the SWT.PASSWORD style. + * + * @param parent the parent + * @param text the initial text + * @param span the horizontal span + * @return the created text + */ public static Text createPasswordText( Composite parent, String text, int span ) { Text t = new Text( parent, SWT.NONE | SWT.BORDER | SWT.PASSWORD ); @@ -125,6 +193,16 @@ } + /** + * Creates a SWT {@link Text} under the given parent. + * The created text control is created with the SWT.PASSWORD and + * SWT.READ_ONLY style. So the created controls is not modifyable. + * + * @param parent the parent + * @param text the initial text + * @param span the horizontal span + * @return the created text + */ public static Text createReadonlyPasswordText( Composite parent, String text, int span ) { Text t = new Text( parent, SWT.NONE | SWT.BORDER | SWT.PASSWORD | SWT.READ_ONLY ); @@ -138,6 +216,17 @@ } + /** + * Creates a SWT {@link Text} under the given parent. + * The created text control behaves like a label: it has no border, + * a grayed background and is not modifyable. + * But the text is selectable and could be copied. + * + * @param parent the parent + * @param text the initial text + * @param span the horizontal span + * @return the created text + */ public static Text createLabeledText( Composite parent, String text, int span ) { Text t = new Text( parent, SWT.NONE ); @@ -151,6 +240,18 @@ } + /** + * Creates a SWT {@link Text} under the given parent. + * The created text control behaves like a label: it has no border, + * a grayed background and is not modifyable. + * But the text is selectable and could be copied. + * The label is created with the SWT.WRAP style to enable line wrapping. + * + * @param parent the parent + * @param text the initial text + * @param span the horizontal span + * @return the created text + */ public static Text createWrappedLabeledText( Composite parent, String text, int span ) { Text t = new Text( parent, SWT.WRAP ); @@ -167,6 +268,16 @@ } + /** + * Creates a SWT {@link Text} under the given parent. + * The text is not modifyable, but the text is selectable + * and could be copied. + * + * @param parent the parent + * @param text the initial text + * @param span the horizontal span + * @return the created text + */ public static Text createReadonlyText( Composite parent, String text, int span ) { Text t = new Text( parent, SWT.NONE | SWT.BORDER | SWT.READ_ONLY ); @@ -180,12 +291,17 @@ } - public static String getNonNullString( String s ) - { - return s == null ? "-" : s; - } - - + /** + * Creates a SWT {@link Combo} under the given parent. + * Beside the selection of an item it is also possible to type + * free text into the combo. + * + * @param parent the parent + * @param items the initial visible items + * @param selectedIndex the initial selected item, zero-based + * @param span the horizontal span + * @return the created combo + */ public static Combo createCombo( Composite parent, String[] items, int selectedIndex, int span ) { Combo c = new Combo( parent, SWT.DROP_DOWN | SWT.BORDER ); @@ -199,6 +315,17 @@ } + /** + * Creates a SWT {@link Combo} under the given parent. + * It is not possible to type free text into the combo, only + * selection of predefined items is possible. + * + * @param parent the parent + * @param items the initial visible items + * @param selectedIndex the initial selected item, zero-based + * @param span the horizontal span + * @return the created combo + */ public static Combo createReadonlyCombo( Composite parent, String[] items, int selectedIndex, int span ) { Combo c = new Combo( parent, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER ); @@ -213,23 +340,17 @@ } - public static Combo createReadonlyReadonlyCombo( Composite parent, String[] items, int selectedIndex, int span ) - { - Combo c = new Combo( parent, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER ); - GridData gd = new GridData( GridData.FILL_HORIZONTAL ); - gd.horizontalSpan = span; - c.setLayoutData( gd ); - c.setBackground( parent.getBackground() ); - c.setItems( items ); - c.select( selectedIndex ); - c.setVisibleItemCount( 20 ); - return c; - } - - - public static Button createCheckbox( Composite composite, String text, int span ) + /** + * Creates a checkbox under the given parent. + * + * @param parent the parent + * @param text the label of the checkbox + * @param span the horizontal span + * @return the created checkbox + */ + public static Button createCheckbox( Composite parent, String text, int span ) { - Button checkbox = new Button( composite, SWT.CHECK ); + Button checkbox = new Button( parent, SWT.CHECK ); checkbox.setText( text ); GridData gd = new GridData(); gd.horizontalSpan = span; @@ -238,9 +359,17 @@ } - public static Button createRadiobutton( Composite composite, String text, int span ) + /** + * Creates a radio button under the given parent. + * + * @param parent the parent + * @param text the label of the radio button + * @param span the horizontal span + * @return the created radio button + */ + public static Button createRadiobutton( Composite parent, String text, int span ) { - Button radio = new Button( composite, SWT.RADIO ); + Button radio = new Button( parent, SWT.RADIO ); radio.setText( text ); GridData gd = new GridData(); gd.horizontalSpan = span; @@ -249,14 +378,23 @@ } - public static Button createButton( Composite composite, String text, int span ) + /** + * Creates a button under the given parent. + * The button width is set to the default width. + * + * @param parent the parent + * @param text the label of the button + * @param span the horizontal span + * @return the created button + */ + public static Button createButton( Composite parent, String text, int span ) { - GC gc = new GC( composite ); + GC gc = new GC( parent ); gc.setFont( JFaceResources.getDialogFont() ); FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); - Button button = new Button( composite, SWT.PUSH ); + Button button = new Button( parent, SWT.PUSH ); GridData gd = new GridData(); gd.widthHint = Dialog.convertHorizontalDLUsToPixels( fontMetrics, IDialogConstants.BUTTON_WIDTH ); button.setLayoutData( gd ); @@ -265,9 +403,15 @@ } - public static void createRadioIndent( Composite composite, int span ) + /** + * Adds some space to indent radio buttons. + * + * @param parent the parent + * @param span the horizontal span + */ + public static void createRadioIndent( Composite parent, int span ) { - Label l = new Label( composite, SWT.NONE ); + Label l = new Label( parent, SWT.NONE ); GridData gd = new GridData(); gd.horizontalSpan = span; gd.horizontalIndent = 22; @@ -275,9 +419,15 @@ } - public static void createSpacer( Composite composite, int span ) + /** + * Creates a spacer. + * + * @param parent the parent + * @param span the horizontal span + */ + public static void createSpacer( Composite parent, int span ) { - Label l = new Label( composite, SWT.NONE ); + Label l = new Label( parent, SWT.NONE ); // GridData gd = new GridData(GridData.FILL_HORIZONTAL); GridData gd = new GridData(); gd.horizontalSpan = span; @@ -286,9 +436,15 @@ } - public static void createSeparator( Composite composite, int span ) + /** + * Creates a separator line. + * + * @param parent the parent + * @param span the horizontal span + */ + public static void createSeparator( Composite parent, int span ) { - Label l = new Label( composite, SWT.SEPARATOR | SWT.HORIZONTAL ); + Label l = new Label( parent, SWT.SEPARATOR | SWT.HORIZONTAL ); GridData gd = new GridData( GridData.FILL_HORIZONTAL ); gd.horizontalSpan = span; // gd.heightHint = 1; @@ -296,6 +452,14 @@ } + /** + * Creates a SWT {@link Link} under the given parent. + * + * @param parent the parent + * @param text the initial text + * @param span the horizontal span + * @return the created text + */ public static Link createLink( Composite parent, String text, int span ) { Link link = new Link( parent, SWT.NONE ); Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/BinaryEncodingInput.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/BinaryEncodingInput.java?view=diff&rev=513539&r1=513538&r2=513539 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/BinaryEncodingInput.java (original) +++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/BinaryEncodingInput.java Thu Mar 1 14:30:01 2007 @@ -24,9 +24,26 @@ import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants; +/** + * The BinaryEncodingInput is an OptionInput with fixed options. + * It is used to select the encoding of binary attributes. The default + * value is always {@link BrowserCoreConstants#BINARYENCODING_IGNORE}. + * The other options are always {@link BrowserCoreConstants#BINARYENCODING_IGNORE}, + * {@link BrowserCoreConstants#BINARYENCODING_BASE64} and + * {@link BrowserCoreConstants#BINARYENCODING_HEX}. No custom input is allowed. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ public class BinaryEncodingInput extends OptionsInput { + /** + * Creates a new instance of BinaryEncodingInput. + * + * @param initialRawValue the initial raw value + * @param asGroup the asGroup flag + */ public BinaryEncodingInput( String initialRawValue, boolean asGroup ) { super( "Binary Encoding", getDefaultDisplayValue(), getDefaultRawValue(), getOtherDisplayValues(), @@ -35,18 +52,34 @@ } + /** + * Gets the default display value, always "Ignore". + * + * @return the default display value + */ private static String getDefaultDisplayValue() { return "Ignore"; } + /** + * Gets the default raw value, always + * {@link BrowserCoreConstants.BINARYENCODING_IGNORE}. + * + * @return the default raw value + */ private static String getDefaultRawValue() { return Integer.toString( BrowserCoreConstants.BINARYENCODING_IGNORE ); } + /** + * Gets the other display values. + * + * @return the other display values + */ private static String[] getOtherDisplayValues() { return new String[] @@ -54,6 +87,11 @@ } + /** + * Gets the other raw values. + * + * @return the other raw values + */ private static String[] getOtherRawValues() { return new String[] Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/BrowserWidget.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/BrowserWidget.java?view=diff&rev=513539&r1=513538&r2=513539 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/BrowserWidget.java (original) +++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/BrowserWidget.java Thu Mar 1 14:30:01 2007 @@ -26,25 +26,48 @@ import java.util.List; +/** + * Base class that provides support for {@link WidgetModifyListener} + * registration and notification. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ public abstract class BrowserWidget { - protected List modifyListenerList; + /** The listener list */ + protected List modifyListenerList; + /** + * Creates a new instance of BrowserWidget. + */ protected BrowserWidget() { - modifyListenerList = new ArrayList( 3 ); + modifyListenerList = new ArrayList( 3 ); } + /** + * Adds the widget modify listener. + * + * @param listener the listener + */ public void addWidgetModifyListener( WidgetModifyListener listener ) { if ( !modifyListenerList.contains( listener ) ) + { modifyListenerList.add( listener ); + } } + /** + * Removes the widget modify listener. + * + * @param listener the listener + */ public void removeWidgetModifyListener( WidgetModifyListener listener ) { if ( modifyListenerList.contains( listener ) ) @@ -52,12 +75,15 @@ } + /** + * Notifies the listeners. + */ protected void notifyListeners() { WidgetModifyEvent event = new WidgetModifyEvent( this ); - for ( Iterator it = modifyListenerList.iterator(); it.hasNext(); ) + for ( Iterator it = modifyListenerList.iterator(); it.hasNext(); ) { - WidgetModifyListener listener = ( WidgetModifyListener ) it.next(); + WidgetModifyListener listener = it.next(); listener.widgetModified( event ); } } Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/DialogContentAssistant.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/DialogContentAssistant.java?view=diff&rev=513539&r1=513538&r2=513539 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/DialogContentAssistant.java (original) +++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/DialogContentAssistant.java Thu Mar 1 14:30:01 2007 @@ -41,46 +41,79 @@ import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; +/** + * The DialogContentAssistant is used to provide content assist and + * a proposal popup within a SWT {@link Text}, {@link Combo} or + * {@link ITextViewer}. + * + * It provides a special handling of ESC keystrokes: + * When the proposal popup is shown ESC is catched and the popup is closed. + * This ensures that a dialog isn't closed on a ESC keystroke + * while the proposal popup is opened. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ public class DialogContentAssistant extends SubjectControlContentAssistant implements FocusListener { + /** The control */ private Control control; + /** The handler activation. */ private IHandlerActivation handlerActivation; + /** The possible completions visible. */ private boolean possibleCompletionsVisible; + /** + * Creates a new instance of DialogContentAssistant. + */ public DialogContentAssistant() { - super(); this.possibleCompletionsVisible = false; } + /** + * Installs content assist on the given text. + * + * @param text the text + */ public void install( Text text ) { - this.control = text; - this.control.addFocusListener( this ); + control = text; + control.addFocusListener( this ); super.install( new TextContentAssistSubjectAdapter( text ) ); } + /** + * Installs content assist on the given combo. + * + * @param combo the combo + */ public void install( Combo combo ) { - this.control = combo; - this.control.addFocusListener( this ); + control = combo; + control.addFocusListener( this ); super.install( new ComboContentAssistSubjectAdapter( combo ) ); } + /** + * Installs content assist on the given text viewer. + * + * @param viewer the text viewer + */ public void install( ITextViewer viewer ) { - this.control = viewer.getTextWidget(); - this.control.addFocusListener( this ); + control = viewer.getTextWidget(); + control.addFocusListener( this ); // stop traversal (ESC) if popup is shown - this.control.addTraverseListener( new TraverseListener() + control.addTraverseListener( new TraverseListener() { public void keyTraversed( TraverseEvent e ) { @@ -95,25 +128,31 @@ } + /** + * Uninstalls content assist on the control. + */ public void uninstall() { - if ( this.handlerActivation != null ) + if ( handlerActivation != null ) { IHandlerService handlerService = ( IHandlerService ) PlatformUI.getWorkbench().getAdapter( IHandlerService.class ); - handlerService.deactivateHandler( this.handlerActivation ); - this.handlerActivation = null; + handlerService.deactivateHandler( handlerActivation ); + handlerActivation = null; } - if ( this.control != null ) + if ( control != null ) { - this.control.removeFocusListener( this ); + control.removeFocusListener( this ); } super.uninstall(); } + /** + * {@inheritDoc} + */ protected Point restoreCompletionProposalPopupSize() { possibleCompletionsVisible = true; @@ -121,6 +160,9 @@ } + /** + * {@inheritDoc} + */ public String showPossibleCompletions() { possibleCompletionsVisible = true; @@ -128,13 +170,19 @@ } + /** + * {@inheritDoc} + */ protected void possibleCompletionsClosed() { - this.possibleCompletionsVisible = false; + possibleCompletionsVisible = false; super.possibleCompletionsClosed(); } + /** + * {@inheritDoc} + */ public void focusGained( FocusEvent e ) { IHandlerService handlerService = ( IHandlerService ) PlatformUI.getWorkbench().getAdapter( @@ -149,20 +197,23 @@ return null; } }; - this.handlerActivation = handlerService.activateHandler( + handlerActivation = handlerService.activateHandler( ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, handler ); } } + /** + * {@inheritDoc} + */ public void focusLost( FocusEvent e ) { - if ( this.handlerActivation != null ) + if ( handlerActivation != null ) { IHandlerService handlerService = ( IHandlerService ) PlatformUI.getWorkbench().getAdapter( IHandlerService.class ); - handlerService.deactivateHandler( this.handlerActivation ); - this.handlerActivation = null; + handlerService.deactivateHandler( handlerActivation ); + handlerActivation = null; } } Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/DnBuilderWidget.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/DnBuilderWidget.java?view=diff&rev=513539&r1=513538&r2=513539 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/DnBuilderWidget.java (original) +++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/DnBuilderWidget.java Thu Mar 1 14:30:01 2007 @@ -29,7 +29,6 @@ import org.apache.directory.ldapstudio.browser.core.model.RDN; import org.apache.directory.ldapstudio.browser.core.model.RDNPart; import org.apache.directory.ldapstudio.browser.ui.widgets.search.EntryWidget; - import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -44,38 +43,59 @@ import org.eclipse.swt.widgets.Text; +/** + * The DnBuilderWidget provides input elements to select a parent DN + * and to build a (multivalued) RDN. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ public class DnBuilderWidget extends BrowserWidget implements ModifyListener { - private IConnection connection; - + /** The attribute names that could be selected from drop-down list. */ private String[] attributeNames; + /** The initial RDN. */ private RDN currentRdn; + /** The initial parent DN. */ private DN currentParentDn; + /** True if the RDN input elements should be shown. */ private boolean showRDN; + /** True if the parent DN input elements should be shown. */ private boolean showParent; + /** The shell. */ private Shell shell; + /** The selected parent DN. */ private DN parentDn; + /** The entry widget to enter/select the parent DN. */ private EntryWidget parentEntryWidget; + /** The composite that contains the RdnLines. */ private Composite rdnComposite; + /** The resulting RDN. */ private RDN rdn; - private ArrayList rdnLineList; + /** The list of RdnLines. */ + private ArrayList rdnLineList; - // private int rdnGroupHeight = -1; - - private Text dnOrRdnText; + /** The preview text. */ + private Text previewText; + /** + * Creates a new instance of DnBuilderWidget. + * + * @param showParent true if the parent DN input elements should be shown + * @param showRDN true if the RDN input elements should be shown + */ public DnBuilderWidget( boolean showRDN, boolean showParent ) { this.showRDN = showRDN; @@ -83,22 +103,33 @@ } + /** + * Disposes this widget. + */ public void dispose() { - } + /** + * Sets the input. + * + * @param rdn the initial RDN + * @param attributeNames the attribute names that could be selected from drop-down list + * @param connection the connection + * @param parentDn the initial parent DN + */ public void setInput( IConnection connection, String[] attributeNames, RDN rdn, DN parentDn ) { - this.connection = connection; - this.attributeNames = attributeNames; + this.currentRdn = rdn; + this.currentParentDn = parentDn; + if ( showRDN ) { - for ( int i = 0; i < this.rdnLineList.size(); i++ ) + for ( int i = 0; i < rdnLineList.size(); i++ ) { - RdnLine rdnLine = ( RdnLine ) this.rdnLineList.get( i ); + RdnLine rdnLine = rdnLineList.get( i ); String oldName = rdnLine.rdnNameCombo.getText(); rdnLine.rdnNameCombo.setItems( attributeNames ); if ( Arrays.asList( rdnLine.rdnNameCombo.getItems() ).contains( oldName ) ) @@ -108,55 +139,70 @@ } } - this.currentRdn = rdn; if ( showRDN ) { while ( !rdnLineList.isEmpty() ) { - deleteRdnLine( this.rdnComposite, 0 ); + deleteRdnLine( rdnComposite, 0 ); } - if ( this.currentRdn == null || this.currentRdn.getParts().length == 0 ) + if ( currentRdn == null || currentRdn.getParts().length == 0 ) { - addRdnLine( this.rdnComposite, 0 ); + addRdnLine( rdnComposite, 0 ); } else { - RDNPart[] parts = this.currentRdn.getParts(); + RDNPart[] parts = currentRdn.getParts(); for ( int i = 0; i < parts.length; i++ ) { - addRdnLine( this.rdnComposite, i ); - ( ( RdnLine ) rdnLineList.get( i ) ).rdnNameCombo.setText( parts[i].getType() ); - ( ( RdnLine ) rdnLineList.get( i ) ).rdnValueText.setText( parts[i].getUnencodedValue() ); + addRdnLine( rdnComposite, i ); + rdnLineList.get( i ).rdnNameCombo.setText( parts[i].getType() ); + rdnLineList.get( i ).rdnValueText.setText( parts[i].getUnencodedValue() ); if ( i == 0 ) { - ( ( RdnLine ) rdnLineList.get( i ) ).rdnValueText.setFocus(); + rdnLineList.get( i ).rdnValueText.setFocus(); } } } } - this.currentParentDn = parentDn; if ( showParent ) { - parentEntryWidget.setInput( this.connection, this.currentParentDn ); + parentEntryWidget.setInput( connection, currentParentDn ); } validate(); } + /** + * Gets the RDN. + * + * @return the RDN + */ public RDN getRdn() { - return this.rdn; + return rdn; } + /** + * Gets the parent DN. + * + * @return the parent DN + */ public DN getParentDn() { - return this.parentDn; + return parentDn; } + /** + * Creates the contents. + * + * @param parent the parent composite + * + * @return the created composite + */ public Composite createContents( Composite parent ) { this.shell = parent.getShell(); @@ -169,8 +215,6 @@ BaseWidgetUtils.createLabel( composite, "Parent:", 1 ); parentEntryWidget = new EntryWidget(); parentEntryWidget.createWidget( composite ); - // parentEntryWidget.setInput(this.connection, - // this.currentParentDn); parentEntryWidget.addWidgetModifyListener( new WidgetModifyListener() { public void widgetModified( WidgetModifyEvent event ) @@ -186,43 +230,47 @@ if ( showRDN ) { BaseWidgetUtils.createLabel( composite, "RDN:", 1 ); - this.rdnComposite = BaseWidgetUtils.createColumnContainer( composite, 5, 2 ); - this.rdnLineList = new ArrayList(); + rdnComposite = BaseWidgetUtils.createColumnContainer( composite, 5, 2 ); + rdnLineList = new ArrayList(); BaseWidgetUtils.createSpacer( composite, 3 ); } // draw dn/rdn preview if ( showRDN ) { - BaseWidgetUtils.createLabel( composite, this.showParent ? "DN Preview: " : "RDN Preview: ", 1 ); - this.dnOrRdnText = BaseWidgetUtils.createReadonlyText( composite, "", 2 ); + BaseWidgetUtils.createLabel( composite, showParent ? "DN Preview: " : "RDN Preview: ", 1 ); + previewText = BaseWidgetUtils.createReadonlyText( composite, "", 2 ); BaseWidgetUtils.createSpacer( composite, 3 ); } - // fill RDN - // if(showRDN) { - // setRdn(currentRdn); - // } - return composite; } + /** + * {@inheritDoc} + */ public void modifyText( ModifyEvent e ) { - this.validate(); + validate(); } + /** + * Saves the dialog settings. + */ public void saveDialogSettings() { - if ( this.parentEntryWidget != null ) + if ( parentEntryWidget != null ) { - this.parentEntryWidget.saveDialogSettings(); + parentEntryWidget.saveDialogSettings(); } } + /** + * Validate. + */ public void validate() { @@ -232,15 +280,15 @@ try { // calculate RDN - String[] rdnNames = new String[this.rdnLineList.size()]; - String[] rdnValues = new String[this.rdnLineList.size()]; - for ( int i = 0; i < this.rdnLineList.size(); i++ ) + String[] rdnNames = new String[rdnLineList.size()]; + String[] rdnValues = new String[rdnLineList.size()]; + for ( int i = 0; i < rdnLineList.size(); i++ ) { - RdnLine rdnLine = ( RdnLine ) this.rdnLineList.get( i ); + RdnLine rdnLine = ( RdnLine ) rdnLineList.get( i ); rdnNames[i] = rdnLine.rdnNameCombo.getText(); rdnValues[i] = rdnLine.rdnValueText.getText(); - if ( this.rdnLineList.size() > 1 ) + if ( rdnLineList.size() > 1 ) { rdnLine.rdnDeleteButton.setEnabled( true ); } @@ -249,12 +297,12 @@ rdnLine.rdnDeleteButton.setEnabled( false ); } } - this.rdn = new RDN( rdnNames, rdnValues, false ); + rdn = new RDN( rdnNames, rdnValues, false ); } catch ( Exception e ) { rdnE = e; - this.rdn = null; + rdn = null; } } @@ -264,12 +312,12 @@ try { // calculate DN - this.parentDn = new DN( parentEntryWidget.getDn() ); + parentDn = new DN( parentEntryWidget.getDn() ); } catch ( Exception e ) { parentE = e; - this.parentDn = null; + parentDn = null; } } @@ -283,24 +331,24 @@ s += ", " + parentE.getMessage() != null ? parentE.getMessage() : "Error in Parent DN "; } - if ( this.dnOrRdnText != null ) + if ( previewText != null ) { if ( s.length() > 0 ) { - this.dnOrRdnText.setText( s ); + previewText.setText( s ); } else { DN dn; - if ( this.showParent && this.showRDN ) + if ( showParent && showRDN ) { dn = new DN( rdn, parentDn ); } - else if ( this.showParent ) + else if ( showParent ) { dn = new DN( parentDn ); } - else if ( this.showRDN ) + else if ( showRDN ) { dn = new DN( rdn ); } @@ -308,7 +356,7 @@ { dn = new DN(); } - this.dnOrRdnText.setText( dn.toString() ); + previewText.setText( dn.toString() ); } } @@ -316,9 +364,14 @@ } - private void addRdnLine( Composite rdnGroup, int index ) + /** + * Adds an RDN line at the given index. + * + * @param rdnComposite the RDN composite + * @param index the index + */ + private void addRdnLine( Composite rdnComposite, int index ) { - RdnLine[] rdnLines = ( RdnLine[] ) rdnLineList.toArray( new RdnLine[rdnLineList.size()] ); if ( rdnLines.length > 0 ) @@ -340,7 +393,7 @@ rdnLineList.remove( oldRdnLine ); // add new - RdnLine newRdnLine = createRdnLine( rdnGroup ); + RdnLine newRdnLine = createRdnLine( rdnComposite ); rdnLineList.add( newRdnLine ); // restore value @@ -350,47 +403,47 @@ // check if ( index == i + 1 ) { - RdnLine rdnLine = createRdnLine( rdnGroup ); + RdnLine rdnLine = createRdnLine( rdnComposite ); rdnLineList.add( rdnLine ); } } } else { - RdnLine rdnLine = createRdnLine( rdnGroup ); + RdnLine rdnLine = createRdnLine( rdnComposite ); rdnLineList.add( rdnLine ); } - // Point shellSize = shell.getSize(); - // Point groupSize = rdnGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT, - // true); - // int newRdnGroupHeight = groupSize.y; - // shell.setSize(shellSize.x, shellSize.y + newRdnGroupHeight - - // rdnGroupHeight); - rdnGroup.layout( true, true ); + rdnComposite.layout( true, true ); shell.layout( true, true ); - // rdnGroupHeight = newRdnGroupHeight; } - private RdnLine createRdnLine( final Composite rdnGroup ) + /** + * Creates and returns an RDN line. + * + * @param rdnComposite the RDN composite + * + * @return the created RDN line + */ + private RdnLine createRdnLine( final Composite rdnComposite ) { final RdnLine rdnLine = new RdnLine(); - rdnLine.rdnNameCombo = new Combo( rdnGroup, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER ); + rdnLine.rdnNameCombo = new Combo( rdnComposite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER ); GridData gd = new GridData(); gd.widthHint = 180; rdnLine.rdnNameCombo.setLayoutData( gd ); rdnLine.rdnNameCombo.setVisibleItemCount( 20 ); - rdnLine.rdnEqualsLabel = new Label( rdnGroup, SWT.NONE ); + rdnLine.rdnEqualsLabel = new Label( rdnComposite, SWT.NONE ); rdnLine.rdnEqualsLabel.setText( "=" ); - rdnLine.rdnValueText = new Text( rdnGroup, SWT.BORDER ); + rdnLine.rdnValueText = new Text( rdnComposite, SWT.BORDER ); gd = new GridData( GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL ); rdnLine.rdnValueText.setLayoutData( gd ); - rdnLine.rdnAddButton = new Button( rdnGroup, SWT.PUSH ); + rdnLine.rdnAddButton = new Button( rdnComposite, SWT.PUSH ); rdnLine.rdnAddButton.setText( " + " ); rdnLine.rdnAddButton.addSelectionListener( new SelectionListener() { @@ -405,7 +458,7 @@ index = i + 1; } } - addRdnLine( rdnGroup, index ); + addRdnLine( rdnComposite, index ); validate(); } @@ -416,7 +469,7 @@ } } ); - rdnLine.rdnDeleteButton = new Button( rdnGroup, SWT.PUSH ); + rdnLine.rdnDeleteButton = new Button( rdnComposite, SWT.PUSH ); rdnLine.rdnDeleteButton.setText( " \u2212 " ); // \u2013 rdnLine.rdnDeleteButton.addSelectionListener( new SelectionListener() { @@ -431,7 +484,7 @@ index = i; } } - deleteRdnLine( rdnGroup, index ); + deleteRdnLine( rdnComposite, index ); validate(); } @@ -442,11 +495,9 @@ } } ); - if ( this.attributeNames != null ) + if ( attributeNames != null ) { - // Subschema subschema = new Subschema(this.attributeNames, - // this.connection.getSchema()); - rdnLine.rdnNameCombo.setItems( this.attributeNames ); + rdnLine.rdnNameCombo.setItems( attributeNames ); } rdnLine.rdnNameCombo.addModifyListener( this ); @@ -456,7 +507,13 @@ } - private void deleteRdnLine( Composite rdnGroup, int index ) + /** + * Delete thd RDN line on the given index. + * + * @param rdnComposite the RDN composite + * @param index the index + */ + private void deleteRdnLine( Composite rdnComposite, int index ) { RdnLine rdnLine = ( RdnLine ) rdnLineList.remove( index ); if ( rdnLine != null ) @@ -467,29 +524,30 @@ rdnLine.rdnAddButton.dispose(); rdnLine.rdnDeleteButton.dispose(); - // Point shellSize = shell.getSize(); - // Point groupSize = rdnGroup.computeSize(SWT.DEFAULT, - // SWT.DEFAULT, - // true); - // int newRdnGroupHeight = groupSize.y; - // shell.setSize(shellSize.x, shellSize.y + newRdnGroupHeight - - // rdnGroupHeight); - rdnGroup.layout( true, true ); + rdnComposite.layout( true, true ); shell.layout( true, true ); - // rdnGroupHeight = newRdnGroupHeight; } } + /** + * The Class RdnLine. + */ public class RdnLine { + + /** The rdn name combo. */ public Combo rdnNameCombo; + /** The rdn value text. */ public Text rdnValueText; + /** The rdn equals label. */ public Label rdnEqualsLabel; + /** The rdn add button. */ public Button rdnAddButton; + /** The rdn delete button. */ public Button rdnDeleteButton; } Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/FileBrowserWidget.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/FileBrowserWidget.java?view=diff&rev=513539&r1=513538&r2=513539 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/FileBrowserWidget.java (original) +++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/FileBrowserWidget.java Thu Mar 1 14:30:01 2007 @@ -36,24 +36,45 @@ import org.eclipse.swt.widgets.FileDialog; +/** + * The FileBrowserWidget provides a combo with a history of recently + * used files an a browse button to open the file browser. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ public class FileBrowserWidget extends BrowserWidget { + /** The Constant TYPE_OPEN is used to create a Open file dialog. */ public static final int TYPE_OPEN = SWT.OPEN; + /** The Constant TYPE_SAVE is used to create a Save file dialog. */ public static final int TYPE_SAVE = SWT.SAVE; + /** The combo with the history of recently used files */ private Combo fileCombo; + /** The button to launch the file browser */ private Button browseButton; + /** The title */ private String title; + /** File extensions used within the lauched file browser */ private String[] extensions; + /** The type */ private int type; + /** + * Creates a new instance of FileBrowserWidget. + * + * @param title The title + * @param extensions The valid file extensions + * @param type The type, one of {@link #TYPE_OPEN} or {@link #TYPE_SAVE} + */ public FileBrowserWidget( String title, String[] extensions, int type ) { this.title = title; @@ -62,6 +83,11 @@ } + /** + * Creates the widget. + * + * @param parent the parent + */ public void createWidget( final Composite parent ) { @@ -119,34 +145,55 @@ } + /** + * Gets the filename. + * + * @return the filename + */ public String getFilename() { - return this.fileCombo.getText(); + return fileCombo.getText(); } + /** + * Sets the filename. + * + * @param filename the filename + */ public void setFilename( String filename ) { - this.fileCombo.setText( filename ); + fileCombo.setText( filename ); } + /** + * Saves dialog settings. + */ public void saveDialogSettings() { - HistoryUtils.save( BrowserUIConstants.DIALOGSETTING_KEY_FILE_HISTORY, this.fileCombo.getText() ); + HistoryUtils.save( BrowserUIConstants.DIALOGSETTING_KEY_FILE_HISTORY, fileCombo.getText() ); } + /** + * Sets the focus. + */ public void setFocus() { fileCombo.setFocus(); } + /** + * Enables or disables the widget. + * + * @param b true to enable the widget, false otherwise + */ public void setEnabled( boolean b ) { - this.fileCombo.setEnabled( b ); - this.browseButton.setEnabled( b ); + fileCombo.setEnabled( b ); + browseButton.setEnabled( b ); } } Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/FileEncodingInput.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/FileEncodingInput.java?view=diff&rev=513539&r1=513538&r2=513539 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/FileEncodingInput.java (original) +++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/FileEncodingInput.java Thu Mar 1 14:30:01 2007 @@ -26,9 +26,25 @@ import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants; +/** + * The FileEncodingInput is an OptionInput with fixed options. + * It is used to select the file encoding. The default + * value is always the platform's default encoding. + * The other options are the values return from + * {@link Charset#availableCharsets()}. No custom input is allowed. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ public class FileEncodingInput extends OptionsInput { + /** + * Creates a new instance of FileEncodingInput. + * + * @param initialRawValue the initial raw value + * @param asGroup the asGroup flag + */ public FileEncodingInput( String initialRawValue, boolean asGroup ) { super( "File Encoding", getDefaultDisplayValue(), getDefaultRawValue(), getOtherDisplayValues(), @@ -37,18 +53,34 @@ } + /** + * Gets the default display value. + * + * @return the default display value + */ private static String getDefaultDisplayValue() { return getCharsetDisplayValue( getDefaultRawValue() ); } + /** + * Gets the default raw value, always the platform's + * default encoding. + * + * @return the default raw value + */ private static String getDefaultRawValue() { return BrowserCoreConstants.DEFAULT_ENCODING; } + /** + * Gets the other display values. + * + * @return the other display values + */ private static String[] getOtherDisplayValues() { String[] otherEncodingsRawValues = getOtherRawValues(); @@ -62,6 +94,12 @@ } + /** + * Gets the other raw values. That are all values + * returned from {@link Charset#availableCharsets()}. + * + * @return the other raw values + */ private static String[] getOtherRawValues() { String[] otherEncodingsRawValues = ( String[] ) Charset.availableCharsets().keySet().toArray( new String[0] ); @@ -69,6 +107,13 @@ } + /** + * Gets the charset display value. + * + * @param charsetRawValue the charset raw value + * + * @return the charset display value + */ private static String getCharsetDisplayValue( String charsetRawValue ) { try Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/HistoryUtils.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/HistoryUtils.java?view=diff&rev=513539&r1=513538&r2=513539 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/HistoryUtils.java (original) +++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/HistoryUtils.java Thu Mar 1 14:30:01 2007 @@ -29,18 +29,32 @@ import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin; +/** + * The HistoryUtils are used to save and load the history of input fields. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ public class HistoryUtils { + /** + * Saves the the given value under the given key in the dialog settings. + * + * @param key the key + * @param value the value + */ public static void save( String key, String value ) { // get current history String[] history = load( key ); - List list = new ArrayList( Arrays.asList( history ) ); + List list = new ArrayList( Arrays.asList( history ) ); // add new value or move to first position if ( list.contains( value ) ) + { list.remove( value ); + } list.add( 0, value ); // check history size @@ -50,12 +64,18 @@ } // save - history = ( String[] ) list.toArray( new String[list.size()] ); + history = list.toArray( new String[list.size()] ); BrowserUIPlugin.getDefault().getDialogSettings().put( key, history ); } + /** + * Loads the value of the given key from the dialog settings + * + * @param key the key + * @return the value + */ public static String[] load( String key ) { String[] history = BrowserUIPlugin.getDefault().getDialogSettings().getArray( key ); Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/LineSeparatorInput.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/LineSeparatorInput.java?view=diff&rev=513539&r1=513538&r2=513539 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/LineSeparatorInput.java (original) +++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/LineSeparatorInput.java Thu Mar 1 14:30:01 2007 @@ -25,13 +25,29 @@ import java.util.Map; import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants; - import org.eclipse.core.runtime.Platform; +/** + * The LineSeparatorInput is an OptionInput with fixed options. + * It is used to select the line separator. The default + * value is always the platform's default line separator. + * The other options are the values return from + * {@link Platform#knownPlatformLineSeparators()}. + * No custom input is allowed. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ public class LineSeparatorInput extends OptionsInput { + /** + * Creates a new instance of LineSeparatorInput. + * + * @param initialRawValue the initial raw value + * @param asGroup the asGroup flag + */ public LineSeparatorInput( String initialRawValue, boolean asGroup ) { super( "Line Separator", getDefaultDisplayValue(), getDefaultRawValue(), getOtherDisplayValues(), @@ -40,6 +56,11 @@ } + /** + * Gets the default display value. + * + * @return the default display value + */ private static String getDefaultDisplayValue() { Map lsMap = Platform.knownPlatformLineSeparators(); @@ -57,16 +78,28 @@ } + /** + * Gets the default raw value, always the platform's default + * line separator. + * + * @return the default raw value + */ private static String getDefaultRawValue() { return BrowserCoreConstants.LINE_SEPARATOR; } + /** + * Gets the other display values That are all values + * returned from {@link Platform#knownPlatformLineSeparators()}. + * + * @return the other display values + */ private static String[] getOtherDisplayValues() { - Map lsMap = Platform.knownPlatformLineSeparators(); - String[] displayValues = ( String[] ) lsMap.keySet().toArray( new String[lsMap.size()] ); + Map lsMap = Platform.knownPlatformLineSeparators(); + String[] displayValues = lsMap.keySet().toArray( new String[lsMap.size()] ); for ( int i = 0; i < displayValues.length; i++ ) { displayValues[i] = displayValues[i] @@ -78,10 +111,15 @@ } + /** + * Gets the other raw values. + * + * @return the other raw values + */ private static String[] getOtherRawValues() { - Map lsMap = Platform.knownPlatformLineSeparators(); - String[] displayValues = ( String[] ) lsMap.keySet().toArray( new String[lsMap.size()] ); + Map lsMap = Platform.knownPlatformLineSeparators(); + String[] displayValues = lsMap.keySet().toArray( new String[lsMap.size()] ); String[] rawValues = new String[displayValues.length]; for ( int i = 0; i < rawValues.length; i++ ) { Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/OptionsInput.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/OptionsInput.java?view=diff&rev=513539&r1=513538&r2=513539 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/OptionsInput.java (original) +++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/OptionsInput.java Thu Mar 1 14:30:01 2007 @@ -23,6 +23,7 @@ import java.util.Arrays; +import org.apache.directory.ldapstudio.browser.ui.dialogs.preferences.TextFormatsPreferencePage; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; @@ -33,34 +34,80 @@ import org.eclipse.swt.widgets.Group; +/** + * The OptionsInput could be used to select one option out of several options. + * It consists of two radio buttons. With the first radio button you could + * select the most likely default option. With the second radio button a combo + * is activated where you could select another option from a drop-down list. + *

+ * Both, the default option and the options in the drop-down list have a raw + * value that is returned by {@link #getRawValue()} and a display value + * that is shown to the user. + *

+ * If the initial raw value is equal to the default raw value then the + * default radio is checked and the drop-down list is disabled. Otherwise + * the second radio is checked, the drop-down list is enabled and the + * initial value is selected. + *

+ * The OptionsInput is used by {@link TextFormatsPreferencePage}. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ public class OptionsInput extends BrowserWidget { + /** The option's title */ private String title; + /** The group, only used when asGroup is true */ private Group titleGroup; + /** The default raw value */ private String defaultRawValue; + /** The default display value */ private String defaultDisplayValue; + /** The radio button to select the default value */ private Button defaultButton; + /** The other raw values */ private String[] otherRawValues; + /** The other display values */ private String[] otherDisplayValues; + /** The radio button to select a value from drop-down list */ private Button otherButton; + /** The combo with the other values */ private Combo otherCombo; + /** The initial raw value */ private String initialRawValue; + /** If true the options are aggregated in a group widget */ private boolean asGroup; + /** If true it is possible to enter a custom value into the combo field */ private boolean allowCustomInput; + /** + * Creates a new instance of OptionsInput. + * + * @param title the option's title + * @param defaultDisplayValue the default display value + * @param defaultRawValue the default raw value + * @param otherDisplayValues the other display values + * @param otherRawValues the other raw vaues + * @param initialRawValue the initial raw value + * @param asGroup a flag indicating if the options should be + * aggregated in a group widget + * @param allowCustomInput true to make it possible to enter a + * custom value into the combo field + */ public OptionsInput( String title, String defaultDisplayValue, String defaultRawValue, String[] otherDisplayValues, String[] otherRawValues, String initialRawValue, boolean asGroup, boolean allowCustomInput ) { @@ -76,6 +123,11 @@ } + /** + * Creates the widget. + * + * @param parent the parent + */ public void createWidget( Composite parent ) { @@ -132,110 +184,30 @@ } } ); - // buttons = new Button[rawValues.length]; - // for (int i = 0; i < rawValues.length; i++) { - // final String rawValue = rawValues[i]; - // Composite buttonComposite = - // BaseWidgetUtils.createColumnContainer(composite, 1, 1); - // buttons[i] = BaseWidgetUtils.createRadiobutton(buttonComposite, - // displayValues[i], 1); - // buttons[i].addSelectionListener(new SelectionAdapter() { - // public void widgetSelected(SelectionEvent e) { - // for (int j = 0; j < buttons.length; j++) { - // if(buttons[j] != e.widget) { - // buttons[j].setSelection(false); - // } - // } - // otherButton.setSelection(false); - // otherText.setEnabled(false); - // selectedRawValue = rawValue; - // notifyListeners(); - // } - // }); - // } - // - // Composite otherComposite = - // BaseWidgetUtils.createColumnContainer(composite, 2, 1); - // otherButton = BaseWidgetUtils.createRadiobutton(otherComposite, - // "Other:", 1); - // otherButton.addSelectionListener(new SelectionAdapter() { - // public void widgetSelected(SelectionEvent e) { - // for (int j = 0; j < buttons.length; j++) { - // buttons[j].setSelection(false); - // } - // otherText.setEnabled(true); - // selectedRawValue = otherText.getText(); - // notifyListeners(); - // } - // }); - // otherText = BaseWidgetUtils.createText(otherComposite, "", 2, 1); - // otherText.setEnabled(otherButton.getSelection()); - // otherText.addModifyListener(new ModifyListener() { - // public void modifyText(ModifyEvent e) { - // selectedRawValue = otherText.getText(); - // notifyListeners(); - // } - // }); - // - // Composite predefinedComposite = - // BaseWidgetUtils.createColumnContainer(composite, 2, 1); - // predefinedButton = - // BaseWidgetUtils.createRadiobutton(predefinedComposite, "", 1); - // predefinedButton.addSelectionListener(new SelectionAdapter() { - // public void widgetSelected(SelectionEvent e) { - // predefinedCombo.setEnabled(true); - // otherButton.setSelection(false); - // otherText.setEnabled(false); - // notifyListeners(); - // } - // }); - // predefinedCombo = - // BaseWidgetUtils.createReadonlyCombo(predefinedComposite, - // displayValues, 0, 1); - // predefinedCombo.addModifyListener(new ModifyListener() { - // public void modifyText(ModifyEvent e) { - // notifyListeners(); - // } - // }); - // - // Composite otherComposite = - // BaseWidgetUtils.createColumnContainer(composite, 2, 1); - // otherButton = BaseWidgetUtils.createRadiobutton(otherComposite, - // "Other:", 1); - // otherButton.addSelectionListener(new SelectionAdapter() { - // public void widgetSelected(SelectionEvent e) { - // predefinedButton.setSelection(false); - // predefinedCombo.setEnabled(false); - // otherText.setEnabled(true); - // notifyListeners(); - // } - // }); - // otherText = BaseWidgetUtils.createText(otherComposite, "", 2, 1); - // otherText.setEnabled(otherButton.getSelection()); - // otherText.addModifyListener(new ModifyListener() { - // public void modifyText(ModifyEvent e) { - // notifyListeners(); - // } - // }); - setRawValue( initialRawValue ); } + /** + * Gets the raw value. Either the default value or + * the selected value from the combo. + * + * @return the raw value + */ public String getRawValue() { - if ( this.defaultButton.getSelection() ) + if ( defaultButton.getSelection() ) { - return this.defaultRawValue; + return defaultRawValue; } else { - String t = this.otherCombo.getText(); - for ( int i = 0; i < this.otherDisplayValues.length; i++ ) + String t = otherCombo.getText(); + for ( int i = 0; i < otherDisplayValues.length; i++ ) { - if ( t.equals( this.otherDisplayValues[i] ) ) + if ( t.equals( otherDisplayValues[i] ) ) { - return this.otherRawValues[i]; + return otherRawValues[i]; } } return t; @@ -243,15 +215,20 @@ } + /** + * Sets the raw value. + * + * @param rawValue the raw value + */ public void setRawValue( String rawValue ) { - int index = Arrays.asList( this.otherRawValues ).indexOf( rawValue ); + int index = Arrays.asList( otherRawValues ).indexOf( rawValue ); if ( index == -1 ) { - index = Arrays.asList( this.otherDisplayValues ).indexOf( rawValue ); + index = Arrays.asList( otherDisplayValues ).indexOf( rawValue ); } - if ( this.defaultRawValue.equals( rawValue ) ) + if ( defaultRawValue.equals( rawValue ) ) { defaultButton.setSelection( true ); otherButton.setSelection( false ); @@ -273,54 +250,5 @@ otherCombo.setText( rawValue ); } } - - // public String getRawValue() { - // if(predefinedButton.getSelection()) { - // int index = predefinedCombo.getSelectionIndex(); - // return rawValues[index]; - // } - // - // return otherText.getText(); - // } - // - // public void setRawValue(String rawValue) { - // - // int index = Arrays.asList(rawValues).indexOf(rawValue); - // if(index > -1) { - // predefinedButton.setSelection(true); - // predefinedCombo.setEnabled(true); - // predefinedCombo.select(index); - // otherButton.setSelection(false); - // otherText.setEnabled(false); - // } - // else { - // predefinedButton.setSelection(false); - // predefinedCombo.setEnabled(false); - // otherButton.setSelection(true); - // otherText.setEnabled(true); - // otherText.setText(rawValue); - // } - // } - - // public String getSelectedRawValue() { - // for (int i = 0; i < buttons.length; i++) { - // Button button = buttons[i]; - // if(button.getSelection()) { - // return rawValues[i]; - // } - // } - // return otherText.getText(); - // } - // - // public void setSelectedRawValue(String rawValue) { - // this.selectedRawValue = rawValue; - // - // for (int i = 0; i < buttons.length; i++) { - // Button button = buttons[i]; - // button.setSelection(rawValue.equals(rawValues[i])); - // } - // otherButton.setSelection(!Arrays.asList(rawValues).contains(rawValue)); - // otherText.setText(otherButton.getSelection() ? rawValue : ""); - // } } Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserCategory.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserCategory.java?view=diff&rev=513539&r1=513538&r2=513539 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserCategory.java (original) +++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserCategory.java Thu Mar 1 14:30:01 2007 @@ -60,6 +60,12 @@ private int type; + /** + * Creates a new instance of BrowserCategory. + * + * @param type the category's type, one of TYPE_DIT, TYPE_SEARCHES or TYPE_BOOKMARKS + * @param parent the category's connection + */ public BrowserCategory( int type, IConnection parent ) { this.parent = parent; Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserSearchResultPage.java URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserSearchResultPage.java?view=diff&rev=513539&r1=513538&r2=513539 ============================================================================== --- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserSearchResultPage.java (original) +++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserSearchResultPage.java Thu Mar 1 14:30:01 2007 @@ -62,7 +62,7 @@ * @param search the parent search * @param first the index of the first child search result in this page * @param last the index of the last child search result in this page - * @param subcontainers the sub pages + * @param subpages the sub pages * @param sorter the sorter */ public BrowserSearchResultPage( ISearch search, int first, int last, BrowserSearchResultPage[] subpages,