in plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/EntryEditorsPreferencePage.java [109:287]
protected Control createContents( Composite parent )
{
Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
// Open Mode Group
BaseWidgetUtils.createSpacer( composite, 1 );
BaseWidgetUtils.createSpacer( composite, 1 );
Group openModeGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ),
Messages.getString( "EntryEditorsPreferencePage.OpenMode" ), 1 ); //$NON-NLS-1$
// Historical Behavior Button
historicalBehaviorButton = BaseWidgetUtils.createRadiobutton( openModeGroup, Messages
.getString( "EntryEditorsPreferencePage.HistoricalBehavior" ), 1 ); //$NON-NLS-1$
Composite historicalBehaviorComposite = BaseWidgetUtils.createColumnContainer( openModeGroup, 2, 1 );
BaseWidgetUtils.createRadioIndent( historicalBehaviorComposite, 1 );
Label historicalBehaviourLabel = BaseWidgetUtils.createWrappedLabel( historicalBehaviorComposite, Messages
.getString( "EntryEditorsPreferencePage.HistoricalBehaviorTooltip" ), 1 ); //$NON-NLS-1$
GridData historicalBehaviourLabelGridData = new GridData( GridData.FILL_HORIZONTAL );
historicalBehaviourLabelGridData.widthHint = 300;
historicalBehaviourLabel.setLayoutData( historicalBehaviourLabelGridData );
// Use Application Wide Open Mode Button
useApplicationWideOpenModeButton = BaseWidgetUtils.createRadiobutton( openModeGroup, Messages
.getString( "EntryEditorsPreferencePage.ApplicationWideSetting" ), 1 ); //$NON-NLS-1$
Composite useApplicationWideOpenModeComposite = BaseWidgetUtils.createColumnContainer( openModeGroup, 2, 1 );
BaseWidgetUtils.createRadioIndent( useApplicationWideOpenModeComposite, 1 );
Link link = BaseWidgetUtils.createLink( useApplicationWideOpenModeComposite, Messages
.getString( "EntryEditorsPreferencePage.ApplicationWideSettingTooltip" ), 1 ); //$NON-NLS-1$
GridData linkGridData = new GridData( GridData.FILL_HORIZONTAL );
linkGridData.widthHint = 300;
link.setLayoutData( linkGridData );
link.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
PreferencesUtil.createPreferenceDialogOn( getShell(),
"org.eclipse.ui.preferencePages.Workbench", null, null ); //$NON-NLS-1$
}
} );
// Initializing the UI from the preferences value
if ( openMode == BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE_HISTORICAL_BEHAVIOR )
{
historicalBehaviorButton.setSelection( true );
useApplicationWideOpenModeButton.setSelection( false );
}
else if ( openMode == BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE_APPLICATION_WIDE )
{
historicalBehaviorButton.setSelection( false );
useApplicationWideOpenModeButton.setSelection( true );
}
// Entry Editors Group
BaseWidgetUtils.createSpacer( composite, 1 );
BaseWidgetUtils.createSpacer( composite, 1 );
Group entryEditorsGroup = BaseWidgetUtils.createGroup(
BaseWidgetUtils.createColumnContainer( composite, 1, 1 ), Messages
.getString( "EntryEditorsPreferencePage.EntryEditors" ), 1 ); //$NON-NLS-1$
// Entry Editors Label
Label entryEditorsLabel = BaseWidgetUtils.createWrappedLabel( entryEditorsGroup, Messages
.getString( "EntryEditorsPreferencePage.EntryEditorsLabel" ), 1 ); //$NON-NLS-1$
GridData entryEditorsLabelGridData = new GridData( GridData.FILL_HORIZONTAL );
entryEditorsLabelGridData.widthHint = 300;
entryEditorsLabel.setLayoutData( entryEditorsLabelGridData );
// Entry Editors Composite
Composite entryEditorsComposite = new Composite( entryEditorsGroup, SWT.NONE );
GridLayout gl = new GridLayout( 2, false );
gl.marginHeight = gl.marginWidth = 0;
entryEditorsComposite.setLayout( gl );
entryEditorsComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// SchemaConnectors TableViewer
entryEditorsTableViewer = new TableViewer( entryEditorsComposite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION );
GridData gridData = new GridData( SWT.FILL, SWT.NONE, true, false, 1, 3 );
gridData.heightHint = 125;
entryEditorsTableViewer.getTable().setLayoutData( gridData );
entryEditorsTableViewer.setContentProvider( new ArrayContentProvider() );
entryEditorsTableViewer.setLabelProvider( new LabelProvider()
{
public String getText( Object element )
{
return ( ( EntryEditorExtension ) element ).getName();
}
public Image getImage( Object element )
{
return ( ( EntryEditorExtension ) element ).getIcon().createImage();
}
} );
entryEditorsTableViewer.setInput( BrowserUIPlugin.getDefault().getEntryEditorManager()
.getEntryEditorExtensions() );
// Up Button
upEntryEditorButton = BaseWidgetUtils.createButton( entryEditorsComposite, Messages
.getString( "EntryEditorsPreferencePage.Up" ), 1 ); //$NON-NLS-1$
upEntryEditorButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
upEntryEditorButton.setEnabled( false );
upEntryEditorButton.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
moveSelectedEntryEditor( MoveEntryEditorDirectionEnum.UP );
}
} );
// Down Button
downEntryEditorButton = BaseWidgetUtils.createButton( entryEditorsComposite, Messages
.getString( "EntryEditorsPreferencePage.Down" ), 1 ); //$NON-NLS-1$
downEntryEditorButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
downEntryEditorButton.setEnabled( false );
downEntryEditorButton.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
moveSelectedEntryEditor( MoveEntryEditorDirectionEnum.DOWN );
}
} );
// Restore Defaults Button
restoreDefaultsEntryEditorsButton = BaseWidgetUtils.createButton( entryEditorsComposite, Messages
.getString( "EntryEditorsPreferencePage.RestoreDefaults" ), 1 ); //$NON-NLS-1$
restoreDefaultsEntryEditorsButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
restoreDefaultsEntryEditorsButton.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
performDefaultsEntryEditors();
}
} );
// Description Label
BaseWidgetUtils.createLabel( entryEditorsGroup, Messages
.getString( "EntryEditorsPreferencePage.DescriptionColon" ), 1 ); //$NON-NLS-1$
// Description Text
final Text descriptionText = new Text( entryEditorsGroup, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY );
descriptionText.setEditable( false );
gridData = new GridData( SWT.FILL, SWT.NONE, true, false );
gridData.heightHint = 27;
gridData.widthHint = 300;
descriptionText.setLayoutData( gridData );
entryEditorsTableViewer.addSelectionChangedListener( new ISelectionChangedListener()
{
public void selectionChanged( SelectionChangedEvent event )
{
// Getting the selected entry editor
EntryEditorExtension entryEditor = ( EntryEditorExtension ) ( ( StructuredSelection ) entryEditorsTableViewer
.getSelection() ).getFirstElement();
if ( entryEditor != null )
{
// Updating the description text field
descriptionText.setText( entryEditor.getDescription() );
// Updating the state of the buttons
updateButtonsState( entryEditor );
}
}
} );
if ( useUserPriority )
{
sortEntryEditorsByUserPriority();
}
else
{
sortEntryEditorsByDefaultPriority();
}
// Selecting the first entry editor
if ( sortedEntryEditorsList.size() > 0 )
{
entryEditorsTableViewer.setSelection( new StructuredSelection( sortedEntryEditorsList.get( 0 ) ) );
}
return composite;
}