You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2006/12/18 18:53:22 UTC
svn commit: r488368 [10/23] - in /directory/sandbox/pamarcelot/ldapstudio:
ldapstudio-browser-ui/ ldapstudio-browser-ui/META-INF/
ldapstudio-browser-ui/about_files/ ldapstudio-browser-ui/icons/
ldapstudio-browser-ui/icons/ovr16/ ldapstudio-browser-ui/s...
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/BinaryAttributesAndSyntaxesPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/BinaryAttributesAndSyntaxesPreferencePage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/BinaryAttributesAndSyntaxesPreferencePage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/BinaryAttributesAndSyntaxesPreferencePage.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,538 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.dialogs.preferences;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.apache.directory.ldapstudio.browser.core.ConnectionManager;
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.schema.AttributeTypeDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.BinaryAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.schema.BinarySyntax;
+import org.apache.directory.ldapstudio.browser.core.model.schema.LdapSyntaxDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+public class BinaryAttributesAndSyntaxesPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+
+ private SortedMap attributeOid2AtdMap;
+
+ private SortedMap attributeNames2AtdMap;
+
+ private String[] attributeNamesAndOids;
+
+ private SortedMap syntaxOid2LsdMap;
+
+ private SortedMap syntaxDesc2LsdMap;
+
+ private String[] syntaxOids;
+
+ private List attributeList;
+
+ private TableViewer attributeViewer;
+
+ private Button attributeAddButton;
+
+ private Button attributeEditButton;
+
+ private Button attributeRemoveButton;
+
+ private List syntaxList;
+
+ private TableViewer syntaxViewer;
+
+ private Button syntaxAddButton;
+
+ private Button syntaxEditButton;
+
+ private Button syntaxRemoveButton;
+
+
+ public BinaryAttributesAndSyntaxesPreferencePage()
+ {
+ super();
+ super.setDescription( "Specify attributes to handle as binary:" );
+ }
+
+
+ public void init( IWorkbench workbench )
+ {
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
+ composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+ // init available attribute types
+ this.attributeNames2AtdMap = new TreeMap();
+ this.attributeOid2AtdMap = new TreeMap();
+ ConnectionManager cm = BrowserCorePlugin.getDefault().getConnectionManager();
+ IConnection[] connections = cm.getConnections();
+ for ( int i = 0; i < connections.length; i++ )
+ {
+ Schema schema = connections[i].getSchema();
+ if ( schema != null )
+ {
+ createAttributeMaps( schema );
+ }
+ }
+ createAttributeMaps( Schema.DEFAULT_SCHEMA );
+ this.attributeNamesAndOids = new String[this.attributeNames2AtdMap.size() + this.attributeOid2AtdMap.size()];
+ System.arraycopy( this.attributeNames2AtdMap.keySet().toArray(), 0, this.attributeNamesAndOids, 0,
+ this.attributeNames2AtdMap.size() );
+ System.arraycopy( this.attributeOid2AtdMap.keySet().toArray(), 0, this.attributeNamesAndOids,
+ this.attributeNames2AtdMap.size(), this.attributeOid2AtdMap.size() );
+
+ // init available syntaxes
+ this.syntaxOid2LsdMap = new TreeMap();
+ this.syntaxDesc2LsdMap = new TreeMap();
+ for ( int i = 0; i < connections.length; i++ )
+ {
+ Schema schema = connections[i].getSchema();
+ if ( schema != null )
+ {
+ createSyntaxMaps( schema );
+ }
+ }
+ createSyntaxMaps( Schema.DEFAULT_SCHEMA );
+ this.syntaxOids = new String[this.syntaxOid2LsdMap.size()];
+ System
+ .arraycopy( this.syntaxOid2LsdMap.keySet().toArray(), 0, this.syntaxOids, 0, this.syntaxOid2LsdMap.size() );
+
+ // create attribute contents
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ createAttributeContents( composite );
+ attributeList = new ArrayList( Arrays.asList( BrowserCorePlugin.getDefault().getCorePreferences()
+ .getBinaryAttributes() ) );
+ attributeViewer.setInput( this.attributeList );
+ attributeViewer.getTable().getColumn( 0 ).pack();
+ // attributeViewer.getTable().getColumn(1).pack();
+ attributeViewer.getTable().pack();
+
+ // create syntax contents
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ createSyntaxContents( composite );
+ syntaxList = new ArrayList( Arrays.asList( BrowserCorePlugin.getDefault().getCorePreferences()
+ .getBinarySyntaxes() ) );
+ syntaxViewer.setInput( this.syntaxList );
+ syntaxViewer.getTable().getColumn( 0 ).pack();
+ // syntaxViewer.getTable().getColumn(1).pack();
+ syntaxViewer.getTable().pack();
+
+ return composite;
+ }
+
+
+ private void createAttributeMaps( Schema schema )
+ {
+ AttributeTypeDescription[] atds = schema.getAttributeTypeDescriptions();
+ for ( int i = 0; i < atds.length; i++ )
+ {
+
+ attributeOid2AtdMap.put( atds[i].getNumericOID(), atds[i] );
+
+ String[] names = atds[i].getNames();
+ for ( int j = 0; j < names.length; j++ )
+ {
+ attributeNames2AtdMap.put( names[j], atds[i] );
+ }
+
+ }
+ }
+
+
+ private void createSyntaxMaps( Schema schema )
+ {
+ LdapSyntaxDescription[] lsds = schema.getLdapSyntaxDescriptions();
+ for ( int i = 0; i < lsds.length; i++ )
+ {
+
+ syntaxOid2LsdMap.put( lsds[i].getNumericOID(), lsds[i] );
+
+ if ( lsds[i].getDesc() != null )
+ {
+ syntaxDesc2LsdMap.put( lsds[i].getDesc(), lsds[i] );
+ }
+
+ }
+ }
+
+
+ private void createAttributeContents( Composite parent )
+ {
+
+ BaseWidgetUtils.createLabel( parent, "Binary Attributes", 1 );
+
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 2, 1 );
+ composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ Composite listComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+ listComposite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ Composite buttonComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+ buttonComposite.setLayoutData( new GridData( GridData.VERTICAL_ALIGN_BEGINNING ) );
+
+ Table table = new Table( listComposite, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION );
+ GridData data = new GridData( GridData.FILL_BOTH );
+ data.widthHint = 360;
+ data.heightHint = convertHeightInCharsToPixels( 10 );
+ table.setLayoutData( data );
+ table.setHeaderVisible( true );
+ table.setLinesVisible( true );
+ attributeViewer = new TableViewer( table );
+
+ TableColumn c1 = new TableColumn( table, SWT.NONE );
+ c1.setText( "Attribute" );
+ c1.setWidth( 300 );
+ TableColumn c2 = new TableColumn( table, SWT.NONE );
+ c2.setText( "Alias" );
+ c2.setWidth( 60 );
+
+ attributeViewer.setColumnProperties( new String[]
+ { "Attribute" } );
+ attributeViewer.setContentProvider( new ArrayContentProvider() );
+ attributeViewer.setLabelProvider( new AttributeLabelProvider() );
+
+ attributeViewer.addDoubleClickListener( new IDoubleClickListener()
+ {
+ public void doubleClick( DoubleClickEvent event )
+ {
+ editAttribute();
+ }
+ } );
+
+ attributeAddButton = BaseWidgetUtils.createButton( buttonComposite, "Add...", 1 );
+ attributeAddButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ addAttribute();
+ }
+ } );
+ attributeEditButton = BaseWidgetUtils.createButton( buttonComposite, "Edit...", 1 );
+ attributeEditButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ editAttribute();
+ }
+ } );
+ attributeRemoveButton = BaseWidgetUtils.createButton( buttonComposite, "Remove", 1 );
+ attributeRemoveButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ removeAttribute();
+ }
+ } );
+
+ // c1.pack();
+ // c2.pack();
+ // table.pack();
+ }
+
+
+ private void createSyntaxContents( Composite parent )
+ {
+
+ BaseWidgetUtils.createLabel( parent, "Binary Syntaxes", 1 );
+
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 2, 1 );
+ composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ Composite listComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+ listComposite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ Composite buttonComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+ buttonComposite.setLayoutData( new GridData( GridData.VERTICAL_ALIGN_BEGINNING ) );
+
+ Table table = new Table( listComposite, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION );
+ GridData data = new GridData( GridData.FILL_BOTH );
+ data.widthHint = 360;
+ data.heightHint = convertHeightInCharsToPixels( 10 );
+ table.setLayoutData( data );
+ table.setHeaderVisible( true );
+ table.setLinesVisible( true );
+ syntaxViewer = new TableViewer( table );
+
+ TableColumn c1 = new TableColumn( table, SWT.NONE );
+ c1.setText( "Syntax" );
+ c1.setWidth( 300 );
+ TableColumn c2 = new TableColumn( table, SWT.NONE );
+ c2.setText( "Desc" );
+ c2.setWidth( 60 );
+
+ syntaxViewer.setColumnProperties( new String[]
+ { "Syntax" } );
+ syntaxViewer.setContentProvider( new ArrayContentProvider() );
+ syntaxViewer.setLabelProvider( new SyntaxLabelProvider() );
+
+ syntaxViewer.addDoubleClickListener( new IDoubleClickListener()
+ {
+ public void doubleClick( DoubleClickEvent event )
+ {
+ editSyntax();
+ }
+ } );
+
+ syntaxAddButton = BaseWidgetUtils.createButton( buttonComposite, "Add...", 1 );
+ syntaxAddButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ addSyntax();
+ }
+ } );
+ syntaxEditButton = BaseWidgetUtils.createButton( buttonComposite, "Edit...", 1 );
+ syntaxEditButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ editSyntax();
+ }
+ } );
+ syntaxRemoveButton = BaseWidgetUtils.createButton( buttonComposite, "Remove", 1 );
+ syntaxRemoveButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ removeSyntax();
+ }
+ } );
+
+ // c1.pack();
+ // c2.pack();
+ // table.pack();
+ }
+
+
+ protected void addAttribute()
+ {
+ AttributeDialog dialog = new AttributeDialog( getShell(), null, this.attributeNamesAndOids );
+ if ( dialog.open() == AttributeValueProviderDialog.OK )
+ {
+ this.attributeList.add( dialog.getAttribute() );
+ this.attributeViewer.refresh();
+ }
+ }
+
+
+ protected void removeAttribute()
+ {
+ Object o = ( ( StructuredSelection ) this.attributeViewer.getSelection() ).getFirstElement();
+ this.attributeList.remove( o );
+ this.attributeViewer.refresh();
+ }
+
+
+ protected void editAttribute()
+ {
+ StructuredSelection sel = ( StructuredSelection ) this.attributeViewer.getSelection();
+ if ( !sel.isEmpty() )
+ {
+ BinaryAttribute attribute = ( BinaryAttribute ) sel.getFirstElement();
+ AttributeDialog dialog = new AttributeDialog( getShell(), attribute, this.attributeNamesAndOids );
+ if ( dialog.open() == AttributeValueProviderDialog.OK )
+ {
+ int index = this.attributeList.indexOf( attribute );
+ this.attributeList.set( index, dialog.getAttribute() );
+ this.attributeViewer.refresh();
+ }
+ }
+ }
+
+
+ protected void addSyntax()
+ {
+ SyntaxDialog dialog = new SyntaxDialog( getShell(), null, this.syntaxOids );
+ if ( dialog.open() == SyntaxValueProviderDialog.OK )
+ {
+ this.syntaxList.add( dialog.getSyntax() );
+ this.syntaxViewer.refresh();
+ }
+ }
+
+
+ protected void removeSyntax()
+ {
+ Object o = ( ( StructuredSelection ) this.syntaxViewer.getSelection() ).getFirstElement();
+ this.syntaxList.remove( o );
+ this.syntaxViewer.refresh();
+ }
+
+
+ protected void editSyntax()
+ {
+ StructuredSelection sel = ( StructuredSelection ) this.syntaxViewer.getSelection();
+ if ( !sel.isEmpty() )
+ {
+ BinarySyntax syntax = ( BinarySyntax ) sel.getFirstElement();
+ SyntaxDialog dialog = new SyntaxDialog( getShell(), syntax, this.syntaxOids );
+ if ( dialog.open() == SyntaxValueProviderDialog.OK )
+ {
+ int index = this.syntaxList.indexOf( syntax );
+ this.syntaxList.set( index, dialog.getSyntax() );
+ this.syntaxViewer.refresh();
+ }
+ }
+ }
+
+
+ public boolean performOk()
+ {
+ BinaryAttribute[] attributes = ( BinaryAttribute[] ) this.attributeList
+ .toArray( new BinaryAttribute[this.attributeList.size()] );
+ BrowserCorePlugin.getDefault().getCorePreferences().setBinaryAttributes( attributes );
+
+ BinarySyntax[] syntaxes = ( BinarySyntax[] ) this.syntaxList.toArray( new BinarySyntax[this.syntaxList.size()] );
+ BrowserCorePlugin.getDefault().getCorePreferences().setBinarySyntaxes( syntaxes );
+
+ return true;
+ }
+
+
+ protected void performDefaults()
+ {
+ this.attributeList.clear();
+ this.attributeList.addAll( Arrays.asList( BrowserCorePlugin.getDefault().getCorePreferences()
+ .getDefaultBinaryAttributes() ) );
+ this.attributeViewer.refresh();
+
+ this.syntaxList.clear();
+ this.syntaxList.addAll( Arrays.asList( BrowserCorePlugin.getDefault().getCorePreferences()
+ .getDefaultBinarySyntaxes() ) );
+ this.syntaxViewer.refresh();
+
+ super.performDefaults();
+ }
+
+ class AttributeLabelProvider extends LabelProvider implements ITableLabelProvider
+ {
+ public String getColumnText( Object obj, int index )
+ {
+ if ( obj instanceof BinaryAttribute )
+ {
+ BinaryAttribute attribute = ( BinaryAttribute ) obj;
+ if ( index == 0 )
+ {
+ return attribute.getAttributeNumericOidOrName();
+ }
+ else if ( index == 1 )
+ {
+ if ( attribute.getAttributeNumericOidOrName() != null )
+ {
+ if ( attributeNames2AtdMap.containsKey( attribute.getAttributeNumericOidOrName() ) )
+ {
+ AttributeTypeDescription atd = ( AttributeTypeDescription ) attributeNames2AtdMap
+ .get( attribute.getAttributeNumericOidOrName() );
+ String s = atd.getNumericOID();
+ for ( int i = 0; i < atd.getNames().length; i++ )
+ {
+ if ( !attribute.getAttributeNumericOidOrName().equals( atd.getNames()[i] ) )
+ {
+ s += ", " + atd.getNames()[i];
+ }
+ }
+ return s;
+ }
+ else if ( attributeOid2AtdMap.containsKey( attribute.getAttributeNumericOidOrName() ) )
+ {
+ AttributeTypeDescription atd = ( AttributeTypeDescription ) attributeOid2AtdMap
+ .get( attribute.getAttributeNumericOidOrName() );
+ return atd.toString();
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+
+ public Image getColumnImage( Object obj, int index )
+ {
+ return null;
+ }
+ }
+
+ class SyntaxLabelProvider extends LabelProvider implements ITableLabelProvider
+ {
+ public String getColumnText( Object obj, int index )
+ {
+ if ( obj instanceof BinarySyntax )
+ {
+ BinarySyntax syntax = ( BinarySyntax ) obj;
+ if ( index == 0 )
+ {
+ return syntax.getSyntaxNumericOid();
+ }
+ else if ( index == 1 )
+ {
+ if ( syntax.getSyntaxNumericOid() != null )
+ {
+ if ( syntaxOid2LsdMap.containsKey( syntax.getSyntaxNumericOid() ) )
+ {
+ LdapSyntaxDescription lsd = ( LdapSyntaxDescription ) syntaxOid2LsdMap.get( syntax
+ .getSyntaxNumericOid() );
+ return lsd.toString();
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+
+ public Image getColumnImage( Object obj, int index )
+ {
+ return null;
+ }
+ }
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/BrowserPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/BrowserPreferencePage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/BrowserPreferencePage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/BrowserPreferencePage.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,351 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.dialogs.preferences;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+public class BrowserPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+
+ private static final String DN = "DN";
+
+ private static final String RDN = "RDN";
+
+ private static final String RDN_VALUE = "RDN value";
+
+ private Combo entryLabelCombo;
+
+ private Button entryAbbreviateButton;
+
+ private Text entryAbbreviateMaxLengthText;
+
+ private Combo searchResultLabelCombo;
+
+ private Button searchResultAbbreviateButton;
+
+ private Text searchResultAbbreviateMaxLengthText;
+
+ private Button enableFoldingButton;
+
+ private Label foldingSizeLabel;
+
+ private Text foldingSizeText;
+
+ private Button expandBaseEntriesButton;;
+
+ private Button checkForChildrenButton;
+
+ private Button showAliasAndReferralObjectsButton;
+
+ private Button fetchSubentriesButton;
+
+
+ public BrowserPreferencePage()
+ {
+ super();
+ super.setPreferenceStore( BrowserUIPlugin.getDefault().getPreferenceStore() );
+ super.setDescription( "General settings for the LDAP browser view:" );
+ }
+
+
+ public void init( IWorkbench workbench )
+ {
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
+
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ Group entryLabelGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ),
+ "Entry label", 1 );
+
+ Composite entryLabelComposite = BaseWidgetUtils.createColumnContainer( entryLabelGroup, 3, 1 );
+ BaseWidgetUtils.createLabel( entryLabelComposite, "Use ", 1 );
+ entryLabelCombo = BaseWidgetUtils.createCombo( entryLabelComposite, new String[]
+ { DN, RDN, RDN_VALUE }, 0, 1 );
+ entryLabelCombo.setLayoutData( new GridData() );
+ entryLabelCombo
+ .select( getPreferenceStore().getInt( BrowserUIConstants.PREFERENCE_BROWSER_ENTRY_LABEL ) == BrowserUIConstants.SHOW_RDN_VALUE ? 2
+ : getPreferenceStore().getInt( BrowserUIConstants.PREFERENCE_BROWSER_ENTRY_LABEL ) == BrowserUIConstants.SHOW_RDN ? 1
+ : 0 );
+ BaseWidgetUtils.createLabel( entryLabelComposite, " as entry label", 1 );
+
+ Composite entryAbbreviateComposite = BaseWidgetUtils.createColumnContainer( entryLabelGroup, 3, 1 );
+ entryAbbreviateButton = BaseWidgetUtils.createCheckbox( entryAbbreviateComposite, "Limit label length to ", 1 );
+ entryAbbreviateButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_BROWSER_ENTRY_ABBREVIATE ) );
+ entryAbbreviateButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ updateEnabled();
+ }
+ } );
+ entryAbbreviateMaxLengthText = BaseWidgetUtils.createText( entryAbbreviateComposite, getPreferenceStore()
+ .getString( BrowserUIConstants.PREFERENCE_BROWSER_ENTRY_ABBREVIATE_MAX_LENGTH ), 3, 1 );
+ entryAbbreviateMaxLengthText.setEnabled( entryAbbreviateButton.getSelection() );
+ entryAbbreviateMaxLengthText.addVerifyListener( new VerifyListener()
+ {
+ public void verifyText( VerifyEvent e )
+ {
+ if ( !e.text.matches( "[0-9]*" ) )
+ {
+ e.doit = false;
+ }
+ if ( "".equals( entryAbbreviateMaxLengthText.getText() ) && e.text.matches( "[0]" ) )
+ {
+ e.doit = false;
+ }
+ }
+ } );
+ BaseWidgetUtils.createLabel( entryAbbreviateComposite, " characters", 1 );
+
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ Group searchResultLabelGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite,
+ 1, 1 ), "Search result label", 1 );
+
+ Composite searchResultLabelComposite = BaseWidgetUtils.createColumnContainer( searchResultLabelGroup, 3, 1 );
+ BaseWidgetUtils.createLabel( searchResultLabelComposite, "Use ", 1 );
+ searchResultLabelCombo = BaseWidgetUtils.createCombo( searchResultLabelComposite, new String[]
+ { DN, RDN, RDN_VALUE }, 0, 1 );
+ searchResultLabelCombo.setLayoutData( new GridData() );
+ searchResultLabelCombo
+ .select( getPreferenceStore().getInt( BrowserUIConstants.PREFERENCE_BROWSER_SEARCH_RESULT_LABEL ) == BrowserUIConstants.SHOW_RDN_VALUE ? 2
+ : getPreferenceStore().getInt( BrowserUIConstants.PREFERENCE_BROWSER_SEARCH_RESULT_LABEL ) == BrowserUIConstants.SHOW_RDN ? 1
+ : 0 );
+ BaseWidgetUtils.createLabel( searchResultLabelComposite, " as search result label", 1 );
+
+ Composite searchResultAbbreviateComposite = BaseWidgetUtils
+ .createColumnContainer( searchResultLabelGroup, 3, 1 );
+ searchResultAbbreviateButton = BaseWidgetUtils.createCheckbox( searchResultAbbreviateComposite,
+ "Limit label length to ", 1 );
+ searchResultAbbreviateButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_BROWSER_SEARCH_RESULT_ABBREVIATE ) );
+ searchResultAbbreviateButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ updateEnabled();
+ }
+ } );
+ searchResultAbbreviateMaxLengthText = BaseWidgetUtils
+ .createText( searchResultAbbreviateComposite, getPreferenceStore().getString(
+ BrowserUIConstants.PREFERENCE_BROWSER_SEARCH_RESULT_ABBREVIATE_MAX_LENGTH ), 3, 1 );
+ searchResultAbbreviateMaxLengthText.setEnabled( searchResultAbbreviateButton.getSelection() );
+ searchResultAbbreviateMaxLengthText.addVerifyListener( new VerifyListener()
+ {
+ public void verifyText( VerifyEvent e )
+ {
+ if ( !e.text.matches( "[0-9]*" ) )
+ {
+ e.doit = false;
+ }
+ if ( "".equals( searchResultAbbreviateMaxLengthText.getText() ) && e.text.matches( "[0]" ) )
+ {
+ e.doit = false;
+ }
+ }
+ } );
+ BaseWidgetUtils.createLabel( searchResultAbbreviateComposite, " characters", 1 );
+
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ Group foldingGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ),
+ "Folding", 1 );
+ Composite pagingGroupComposite = BaseWidgetUtils.createColumnContainer( foldingGroup, 2, 1 );
+ enableFoldingButton = BaseWidgetUtils.createCheckbox( pagingGroupComposite, "Enable folding", 2 );
+ enableFoldingButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_BROWSER_ENABLE_FOLDING ) );
+ enableFoldingButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ updateEnabled();
+ }
+ } );
+ foldingSizeLabel = BaseWidgetUtils.createLabel( pagingGroupComposite, "Folding size: ", 1 );
+ foldingSizeLabel.setEnabled( enableFoldingButton.getSelection() );
+ foldingSizeText = BaseWidgetUtils.createText( pagingGroupComposite, getPreferenceStore().getString(
+ BrowserUIConstants.PREFERENCE_BROWSER_FOLDING_SIZE ), 4, 1 );
+ foldingSizeText.setEnabled( enableFoldingButton.getSelection() );
+ foldingSizeText.addVerifyListener( new VerifyListener()
+ {
+ public void verifyText( VerifyEvent e )
+ {
+ if ( !e.text.matches( "[0-9]*" ) )
+ {
+ e.doit = false;
+ }
+ if ( "".equals( foldingSizeText.getText() ) && e.text.matches( "[0]" ) )
+ {
+ e.doit = false;
+ }
+ }
+ } );
+
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ expandBaseEntriesButton = BaseWidgetUtils.createCheckbox( composite,
+ "Expand base entries when opening connection", 1 );
+ expandBaseEntriesButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_BROWSER_EXPAND_BASE_ENTRIES ) );
+ Preferences coreStore = BrowserCorePlugin.getDefault().getPluginPreferences();
+ checkForChildrenButton = BaseWidgetUtils.createCheckbox( composite, "Check for children", 1 );
+ checkForChildrenButton
+ .setSelection( coreStore.getBoolean( BrowserCoreConstants.PREFERENCE_CHECK_FOR_CHILDREN ) );
+ showAliasAndReferralObjectsButton = BaseWidgetUtils.createCheckbox( composite,
+ "Show alias and referral objects", 1 );
+ showAliasAndReferralObjectsButton.setSelection( coreStore
+ .getBoolean( BrowserCoreConstants.PREFERENCE_SHOW_ALIAS_AND_REFERRAL_OBJECTS ) );
+ fetchSubentriesButton = BaseWidgetUtils.createCheckbox( composite,
+ "Fetch subentries (requires additional search request)", 1 );
+ fetchSubentriesButton.setSelection( coreStore.getBoolean( BrowserCoreConstants.PREFERENCE_FETCH_SUBENTRIES ) );
+
+ updateEnabled();
+
+ applyDialogFont( composite );
+
+ return composite;
+ }
+
+
+ private void updateEnabled()
+ {
+ entryAbbreviateMaxLengthText.setEnabled( entryAbbreviateButton.getSelection() );
+ searchResultAbbreviateMaxLengthText.setEnabled( searchResultAbbreviateButton.getSelection() );
+ foldingSizeText.setEnabled( enableFoldingButton.getSelection() );
+ foldingSizeLabel.setEnabled( enableFoldingButton.getSelection() );
+ }
+
+
+ public boolean performOk()
+ {
+
+ Preferences coreStore = BrowserCorePlugin.getDefault().getPluginPreferences();
+ coreStore.setValue( BrowserCoreConstants.PREFERENCE_CHECK_FOR_CHILDREN, this.checkForChildrenButton
+ .getSelection() );
+ coreStore.setValue( BrowserCoreConstants.PREFERENCE_SHOW_ALIAS_AND_REFERRAL_OBJECTS,
+ this.showAliasAndReferralObjectsButton.getSelection() );
+ coreStore
+ .setValue( BrowserCoreConstants.PREFERENCE_FETCH_SUBENTRIES, this.fetchSubentriesButton.getSelection() );
+ BrowserCorePlugin.getDefault().savePluginPreferences();
+
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_BROWSER_EXPAND_BASE_ENTRIES,
+ this.expandBaseEntriesButton.getSelection() );
+
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_BROWSER_ENABLE_FOLDING,
+ this.enableFoldingButton.getSelection() );
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_BROWSER_FOLDING_SIZE,
+ this.foldingSizeText.getText().trim() );
+
+ getPreferenceStore().setValue(
+ BrowserUIConstants.PREFERENCE_BROWSER_ENTRY_LABEL,
+ this.entryLabelCombo.getSelectionIndex() == 2 ? BrowserUIConstants.SHOW_RDN_VALUE : this.entryLabelCombo
+ .getSelectionIndex() == 1 ? BrowserUIConstants.SHOW_RDN : BrowserUIConstants.SHOW_DN );
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_BROWSER_ENTRY_ABBREVIATE,
+ this.entryAbbreviateButton.getSelection() );
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_BROWSER_ENTRY_ABBREVIATE_MAX_LENGTH,
+ this.entryAbbreviateMaxLengthText.getText().trim() );
+
+ getPreferenceStore().setValue(
+ BrowserUIConstants.PREFERENCE_BROWSER_SEARCH_RESULT_LABEL,
+ this.searchResultLabelCombo.getSelectionIndex() == 2 ? BrowserUIConstants.SHOW_RDN_VALUE
+ : this.searchResultLabelCombo.getSelectionIndex() == 1 ? BrowserUIConstants.SHOW_RDN
+ : BrowserUIConstants.SHOW_DN );
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_BROWSER_SEARCH_RESULT_ABBREVIATE,
+ this.searchResultAbbreviateButton.getSelection() );
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_BROWSER_SEARCH_RESULT_ABBREVIATE_MAX_LENGTH,
+ this.searchResultAbbreviateMaxLengthText.getText().trim() );
+
+ return true;
+ }
+
+
+ protected void performDefaults()
+ {
+
+ entryLabelCombo
+ .select( getPreferenceStore().getDefaultInt( BrowserUIConstants.PREFERENCE_BROWSER_ENTRY_LABEL ) == BrowserUIConstants.SHOW_RDN_VALUE ? 2
+ : getPreferenceStore().getDefaultInt( BrowserUIConstants.PREFERENCE_BROWSER_ENTRY_LABEL ) == BrowserUIConstants.SHOW_RDN ? 1
+ : 0 );
+ entryAbbreviateButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserUIConstants.PREFERENCE_BROWSER_ENTRY_ABBREVIATE ) );
+ entryAbbreviateMaxLengthText.setText( getPreferenceStore().getDefaultString(
+ BrowserUIConstants.PREFERENCE_BROWSER_ENTRY_ABBREVIATE_MAX_LENGTH ) );
+
+ searchResultLabelCombo
+ .select( getPreferenceStore().getDefaultInt( BrowserUIConstants.PREFERENCE_BROWSER_SEARCH_RESULT_LABEL ) == BrowserUIConstants.SHOW_RDN_VALUE ? 2
+ : getPreferenceStore().getDefaultInt( BrowserUIConstants.PREFERENCE_BROWSER_SEARCH_RESULT_LABEL ) == BrowserUIConstants.SHOW_RDN ? 1
+ : 0 );
+ searchResultAbbreviateButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserUIConstants.PREFERENCE_BROWSER_SEARCH_RESULT_ABBREVIATE ) );
+ searchResultAbbreviateMaxLengthText.setText( getPreferenceStore().getDefaultString(
+ BrowserUIConstants.PREFERENCE_BROWSER_SEARCH_RESULT_ABBREVIATE_MAX_LENGTH ) );
+
+ enableFoldingButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserUIConstants.PREFERENCE_BROWSER_ENABLE_FOLDING ) );
+ foldingSizeText.setText( getPreferenceStore().getDefaultString(
+ BrowserUIConstants.PREFERENCE_BROWSER_FOLDING_SIZE ) );
+
+ expandBaseEntriesButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserUIConstants.PREFERENCE_BROWSER_EXPAND_BASE_ENTRIES ) );
+ Preferences coreStore = BrowserCorePlugin.getDefault().getPluginPreferences();
+ checkForChildrenButton.setSelection( coreStore
+ .getDefaultBoolean( BrowserCoreConstants.PREFERENCE_CHECK_FOR_CHILDREN ) );
+ showAliasAndReferralObjectsButton.setSelection( coreStore
+ .getDefaultBoolean( BrowserCoreConstants.PREFERENCE_SHOW_ALIAS_AND_REFERRAL_OBJECTS ) );
+ fetchSubentriesButton.setSelection( coreStore
+ .getDefaultBoolean( BrowserCoreConstants.PREFERENCE_FETCH_SUBENTRIES ) );
+
+ updateEnabled();
+
+ super.performDefaults();
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/EntryEditorPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/EntryEditorPreferencePage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/EntryEditorPreferencePage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/EntryEditorPreferencePage.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.dialogs.preferences;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+public class EntryEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+
+ private Button showObjectClassAttributeButton;
+
+ private Button showMustAttributesButton;
+
+ private Button showMayAttributesButton;
+
+ private Button showOperationalAttributesButton;
+
+ private Button enableFoldingButton;
+
+ private Label foldingThresholdLabel;
+
+ private Text foldingThresholdText;
+
+
+ public EntryEditorPreferencePage()
+ {
+ super();
+ super.setPreferenceStore( BrowserUIPlugin.getDefault().getPreferenceStore() );
+ super.setDescription( "General settings for the LDAP entry editor:" );
+ }
+
+
+ public void init( IWorkbench workbench )
+ {
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
+
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ Group visibleAttributesGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite,
+ 1, 1 ), "Visible Attributes", 1 );
+ Composite visibleAttributesComposite = BaseWidgetUtils.createColumnContainer( visibleAttributesGroup, 1, 1 );
+ showObjectClassAttributeButton = BaseWidgetUtils.createCheckbox( visibleAttributesComposite,
+ "Show objectClass attribute", 1 );
+ showObjectClassAttributeButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_ENTRYEDITOR_SHOW_OBJECTCLASS_ATTRIBUTES ) );
+ showMustAttributesButton = BaseWidgetUtils.createCheckbox( visibleAttributesComposite, "Show must attributes",
+ 1 );
+ showMustAttributesButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_ENTRYEDITOR_SHOW_MUST_ATTRIBUTES ) );
+ showMayAttributesButton = BaseWidgetUtils.createCheckbox( visibleAttributesComposite, "Show may attributes", 1 );
+ showMayAttributesButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_ENTRYEDITOR_SHOW_MAY_ATTRIBUTES ) );
+ showOperationalAttributesButton = BaseWidgetUtils.createCheckbox( visibleAttributesComposite,
+ "Show operational attributes", 1 );
+ showOperationalAttributesButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_ENTRYEDITOR_SHOW_OPERATIONAL_ATTRIBUTES ) );
+
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ String foldingTooltip = "If an attribute has more than the specified number of values it will be folded to one line. You may expand and collapse the values.";
+ Group foldingGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ),
+ "Folding", 1 );
+ Composite pagingGroupComposite = BaseWidgetUtils.createColumnContainer( foldingGroup, 2, 1 );
+ enableFoldingButton = BaseWidgetUtils.createCheckbox( pagingGroupComposite, "Enable folding", 2 );
+ enableFoldingButton.setToolTipText( foldingTooltip );
+ enableFoldingButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_ENTRYEDITOR_ENABLE_FOLDING ) );
+ enableFoldingButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ updateEnabled();
+ }
+ } );
+ foldingThresholdLabel = BaseWidgetUtils.createLabel( pagingGroupComposite, "Folding threshold: ", 1 );
+ foldingThresholdLabel.setToolTipText( foldingTooltip );
+ foldingThresholdLabel.setEnabled( enableFoldingButton.getSelection() );
+ foldingThresholdText = BaseWidgetUtils.createText( pagingGroupComposite, getPreferenceStore().getString(
+ BrowserUIConstants.PREFERENCE_ENTRYEDITOR_FOLDING_THRESHOLD ), 4, 1 );
+ foldingThresholdText.setToolTipText( foldingTooltip );
+ foldingThresholdText.setEnabled( enableFoldingButton.getSelection() );
+ foldingThresholdText.addVerifyListener( new VerifyListener()
+ {
+ public void verifyText( VerifyEvent e )
+ {
+ if ( !e.text.matches( "[0-9]*" ) )
+ {
+ e.doit = false;
+ }
+ if ( "".equals( foldingThresholdText.getText() ) && e.text.matches( "[0]" ) )
+ {
+ e.doit = false;
+ }
+ }
+ } );
+
+ updateEnabled();
+
+ applyDialogFont( composite );
+
+ return composite;
+ }
+
+
+ private void updateEnabled()
+ {
+ foldingThresholdText.setEnabled( enableFoldingButton.getSelection() );
+ foldingThresholdLabel.setEnabled( enableFoldingButton.getSelection() );
+ }
+
+
+ public boolean performOk()
+ {
+
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_ENTRYEDITOR_SHOW_OBJECTCLASS_ATTRIBUTES,
+ this.showObjectClassAttributeButton.getSelection() );
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_ENTRYEDITOR_SHOW_MUST_ATTRIBUTES,
+ this.showMustAttributesButton.getSelection() );
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_ENTRYEDITOR_SHOW_MAY_ATTRIBUTES,
+ this.showMayAttributesButton.getSelection() );
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_ENTRYEDITOR_SHOW_OPERATIONAL_ATTRIBUTES,
+ this.showOperationalAttributesButton.getSelection() );
+
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_ENTRYEDITOR_ENABLE_FOLDING,
+ this.enableFoldingButton.getSelection() );
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_ENTRYEDITOR_FOLDING_THRESHOLD,
+ this.foldingThresholdText.getText() );
+
+ return true;
+ }
+
+
+ protected void performDefaults()
+ {
+
+ this.showObjectClassAttributeButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserUIConstants.PREFERENCE_ENTRYEDITOR_SHOW_OBJECTCLASS_ATTRIBUTES ) );
+ this.showMustAttributesButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserUIConstants.PREFERENCE_ENTRYEDITOR_SHOW_MUST_ATTRIBUTES ) );
+ this.showMayAttributesButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserUIConstants.PREFERENCE_ENTRYEDITOR_SHOW_MAY_ATTRIBUTES ) );
+ this.showOperationalAttributesButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserUIConstants.PREFERENCE_ENTRYEDITOR_SHOW_OPERATIONAL_ATTRIBUTES ) );
+
+ this.foldingThresholdText.setText( getPreferenceStore().getDefaultString(
+ BrowserUIConstants.PREFERENCE_ENTRYEDITOR_FOLDING_THRESHOLD ) );
+
+ updateEnabled();
+
+ super.performDefaults();
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/LdifEditorContentAssistPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/LdifEditorContentAssistPreferencePage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/LdifEditorContentAssistPreferencePage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/LdifEditorContentAssistPreferencePage.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.dialogs.preferences;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+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.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+public class LdifEditorContentAssistPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+
+ private Button insertSingleProposalAutoButton;
+
+ private Button enableAutoActivationButton;
+
+ private Label autoActivationDelayLabel;
+
+ private Text autoActivationDelayText;
+
+ private Label autoActivationDelayMs;
+
+ private Button smartInsertAttributeInModspecButton;
+
+
+ public LdifEditorContentAssistPreferencePage()
+ {
+ super( "Content Assist" );
+ super.setPreferenceStore( BrowserUIPlugin.getDefault().getPreferenceStore() );
+ super.setDescription( "General settings for attributes:" );
+ }
+
+
+ public void init( IWorkbench workbench )
+ {
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ Composite composite = new Composite( parent, SWT.NONE );
+ GridLayout layout = new GridLayout( 1, false );
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.marginLeft = 0;
+ layout.marginRight = 0;
+ layout.marginTop = 0;
+ layout.marginBottom = 0;
+ composite.setLayout( layout );
+ GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+ composite.setLayoutData( gd );
+
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+
+ Group caGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ),
+ "Content Assist", 1 );
+
+ insertSingleProposalAutoButton = BaseWidgetUtils.createCheckbox( caGroup,
+ "Insert single proposal automatically", 1 );
+ insertSingleProposalAutoButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_INSERTSINGLEPROPOSALAUTO ) );
+
+ enableAutoActivationButton = BaseWidgetUtils.createCheckbox( caGroup, "Enable auto activation", 1 );
+ enableAutoActivationButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_ENABLEAUTOACTIVATION ) );
+ enableAutoActivationButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ checkEnabled();
+ }
+ } );
+
+ Composite autoActivationDelayComposite = BaseWidgetUtils.createColumnContainer( caGroup, 4, 1 );
+ BaseWidgetUtils.createRadioIndent( autoActivationDelayComposite, 1 );
+ autoActivationDelayLabel = BaseWidgetUtils.createLabel( autoActivationDelayComposite, "Auto activation delay:",
+ 1 );
+ autoActivationDelayText = BaseWidgetUtils.createText( autoActivationDelayComposite, "", 4, 1 );
+ autoActivationDelayText.setText( getPreferenceStore().getString(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_AUTOACTIVATIONDELAY ) );
+ autoActivationDelayText.addVerifyListener( new VerifyListener()
+ {
+ public void verifyText( VerifyEvent e )
+ {
+ if ( !e.text.matches( "[0-9]*" ) )
+ {
+ e.doit = false;
+ }
+ if ( "".equals( autoActivationDelayText.getText() ) && e.text.matches( "[0]" ) )
+ {
+ e.doit = false;
+ }
+ }
+ } );
+ autoActivationDelayMs = BaseWidgetUtils.createLabel( autoActivationDelayComposite, "ms", 1 );
+
+ smartInsertAttributeInModspecButton = BaseWidgetUtils.createCheckbox( caGroup,
+ "Smart insert attribute name in modification items", 1 );
+ smartInsertAttributeInModspecButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_SMARTINSERTATTRIBUTEINMODSPEC ) );
+ BaseWidgetUtils.createLabel( caGroup, "TODO: Smart insert must attributes", 1 );
+
+ checkEnabled();
+
+ return composite;
+ }
+
+
+ private void checkEnabled()
+ {
+ autoActivationDelayLabel.setEnabled( enableAutoActivationButton.getSelection() );
+ autoActivationDelayText.setEnabled( enableAutoActivationButton.getSelection() );
+ autoActivationDelayMs.setEnabled( enableAutoActivationButton.getSelection() );
+ }
+
+
+ public boolean performOk()
+ {
+
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_INSERTSINGLEPROPOSALAUTO,
+ this.insertSingleProposalAutoButton.getSelection() );
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_ENABLEAUTOACTIVATION,
+ this.enableAutoActivationButton.getSelection() );
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_AUTOACTIVATIONDELAY,
+ this.autoActivationDelayText.getText() );
+ getPreferenceStore().setValue(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_SMARTINSERTATTRIBUTEINMODSPEC,
+ this.smartInsertAttributeInModspecButton.getSelection() );
+
+ BrowserCorePlugin.getDefault().savePluginPreferences();
+
+ return true;
+ }
+
+
+ protected void performDefaults()
+ {
+
+ insertSingleProposalAutoButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_INSERTSINGLEPROPOSALAUTO ) );
+ enableAutoActivationButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_ENABLEAUTOACTIVATION ) );
+ autoActivationDelayText.setText( getPreferenceStore().getDefaultString(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_AUTOACTIVATIONDELAY ) );
+ smartInsertAttributeInModspecButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_SMARTINSERTATTRIBUTEINMODSPEC ) );
+
+ super.performDefaults();
+
+ checkEnabled();
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/LdifEditorPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/LdifEditorPreferencePage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/LdifEditorPreferencePage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/LdifEditorPreferencePage.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,217 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.dialogs.preferences;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+
+import org.eclipse.jface.preference.PreferencePage;
+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.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+
+public class LdifEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+
+ // private Button autoWrapButton;
+
+ private Button enableFoldingButton;
+
+ private Label initiallyFoldLabel;
+
+ private Button initiallyFoldCommentsButton;
+
+ private Button initiallyFoldRecordsButton;
+
+ private Button initiallyFoldWrappedLinesButton;
+
+ private Button useLdifDoubleClickButton;
+
+
+ public LdifEditorPreferencePage()
+ {
+ super( "LDIF Editor" );
+ super.setPreferenceStore( BrowserUIPlugin.getDefault().getPreferenceStore() );
+ }
+
+
+ public void init( IWorkbench workbench )
+ {
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ Composite composite = new Composite( parent, SWT.NONE );
+ GridLayout layout = new GridLayout( 1, false );
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.marginLeft = 0;
+ layout.marginRight = 0;
+ layout.marginTop = 0;
+ layout.marginBottom = 0;
+ composite.setLayout( layout );
+ composite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+ String text = "See <a>Text Editors</a> for the general text editor preferences.";
+ Link link = BaseWidgetUtils.createLink( composite, text, 1 );
+ link.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ PreferencesUtil.createPreferenceDialogOn( getShell(),
+ "org.eclipse.ui.preferencePages.GeneralTextEditor", null, null ); //$NON-NLS-1$
+ }
+ } );
+ String text2 = "See <a>Text Formats</a> for LDIF format preferences.";
+ Link link2 = BaseWidgetUtils.createLink( composite, text2, 1 );
+ link2.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ PreferencesUtil.createPreferenceDialogOn( getShell(), TextFormatsPreferencePage.class.getName(), null,
+ null ); //$NON-NLS-1$
+ }
+ } );
+
+ // BaseWidgetUtils.createSpacer(composite, 1);
+ // BaseWidgetUtils.createSpacer(composite, 1);
+ // autoWrapButton = BaseWidgetUtils.createCheckbox(formatGroup, "Wrap
+ // automatically", 1);
+ // autoWrapButton.setSelection(getPreferenceStore().getBoolean(BrowserUIConstants.PREFERENCE_LDIFEDITOR_FORMATTER_AUTOWRAP));
+ // autoWrapButton.setEnabled(false);
+
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+
+ Group foldGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ),
+ "Folding", 1 );
+
+ enableFoldingButton = BaseWidgetUtils.createCheckbox( foldGroup, "Enable Folding", 1 );
+ enableFoldingButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_FOLDING_ENABLE ) );
+ enableFoldingButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ checkEnabled();
+ }
+ } );
+
+ Composite initiallyFoldComposiste = BaseWidgetUtils.createColumnContainer( foldGroup, 4, 1 );
+ initiallyFoldLabel = BaseWidgetUtils.createLabel( initiallyFoldComposiste, "Initially fold:", 1 );
+ initiallyFoldCommentsButton = BaseWidgetUtils.createCheckbox( initiallyFoldComposiste, "Comments", 1 );
+ initiallyFoldCommentsButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDCOMMENTS ) );
+ initiallyFoldRecordsButton = BaseWidgetUtils.createCheckbox( initiallyFoldComposiste, "Records", 1 );
+ initiallyFoldRecordsButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDRECORDS ) );
+ initiallyFoldWrappedLinesButton = BaseWidgetUtils.createCheckbox( initiallyFoldComposiste, "Wrapped lines", 1 );
+ initiallyFoldWrappedLinesButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDWRAPPEDLINES ) );
+
+ BaseWidgetUtils.createSpacer( composite, 1 );
+
+ Group doubleClickGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ),
+ "Double Click Behaviour", 1 );
+ useLdifDoubleClickButton = BaseWidgetUtils.createCheckbox( doubleClickGroup,
+ "Select whole attribute or value on double click", 1 );
+ useLdifDoubleClickButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_DOUBLECLICK_USELDIFDOUBLECLICK ) );
+
+ checkEnabled();
+
+ return composite;
+ }
+
+
+ private void checkEnabled()
+ {
+ initiallyFoldLabel.setEnabled( enableFoldingButton.getSelection() );
+ initiallyFoldCommentsButton.setEnabled( enableFoldingButton.getSelection() );
+ initiallyFoldRecordsButton.setEnabled( enableFoldingButton.getSelection() );
+ initiallyFoldWrappedLinesButton.setEnabled( enableFoldingButton.getSelection() );
+ }
+
+
+ public boolean performOk()
+ {
+
+ // getPreferenceStore().setValue(BrowserUIConstants.PREFERENCE_LDIFEDITOR_FORMATTER_AUTOWRAP,
+ // this.autoWrapButton.getSelection());
+
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_LDIFEDITOR_FOLDING_ENABLE,
+ this.enableFoldingButton.getSelection() );
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDCOMMENTS,
+ this.initiallyFoldCommentsButton.getSelection() );
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDRECORDS,
+ this.initiallyFoldRecordsButton.getSelection() );
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDWRAPPEDLINES,
+ this.initiallyFoldWrappedLinesButton.getSelection() );
+
+ getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_LDIFEDITOR_DOUBLECLICK_USELDIFDOUBLECLICK,
+ this.useLdifDoubleClickButton.getSelection() );
+
+ BrowserCorePlugin.getDefault().savePluginPreferences();
+
+ return true;
+ }
+
+
+ protected void performDefaults()
+ {
+
+ // autoWrapButton.setSelection(getPreferenceStore().getDefaultBoolean(BrowserUIConstants.PREFERENCE_LDIFEDITOR_FORMATTER_AUTOWRAP));
+
+ enableFoldingButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_FOLDING_ENABLE ) );
+ initiallyFoldCommentsButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDCOMMENTS ) );
+ initiallyFoldRecordsButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDRECORDS ) );
+ initiallyFoldWrappedLinesButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDWRAPPEDLINES ) );
+
+ useLdifDoubleClickButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_DOUBLECLICK_USELDIFDOUBLECLICK ) );
+
+ super.performDefaults();
+
+ checkEnabled();
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/LdifEditorSyntaxColoringPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/LdifEditorSyntaxColoringPreferencePage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/LdifEditorSyntaxColoringPreferencePage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/LdifEditorSyntaxColoringPreferencePage.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,473 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.dialogs.preferences;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifFile;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.editors.ldif.ILdifEditor;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.ldifeditor.LdifEditorWidget;
+
+import org.eclipse.jface.preference.ColorSelector;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.RGB;
+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.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+public class LdifEditorSyntaxColoringPreferencePage extends PreferencePage implements IWorkbenchPreferencePage,
+ ILdifEditor
+{
+
+ private static final String LDIF_INITIAL = "" + "# Content record" + BrowserCoreConstants.LINE_SEPARATOR
+ + "dn: cn=content record" + BrowserCoreConstants.LINE_SEPARATOR + "objectClass: person"
+ + BrowserCoreConstants.LINE_SEPARATOR + "cn: content record" + BrowserCoreConstants.LINE_SEPARATOR
+ + "cn;lang-ja:: 5Za25qWt6YOo" + BrowserCoreConstants.LINE_SEPARATOR + "" + BrowserCoreConstants.LINE_SEPARATOR
+
+ + "# Add record with control" + BrowserCoreConstants.LINE_SEPARATOR + "dn: cn=add record"
+ + BrowserCoreConstants.LINE_SEPARATOR + "control: 1.2.3.4 true: controlValue"
+ + BrowserCoreConstants.LINE_SEPARATOR + "changetype: add" + BrowserCoreConstants.LINE_SEPARATOR
+ + "objectClass: person" + BrowserCoreConstants.LINE_SEPARATOR + "cn: add record"
+ + BrowserCoreConstants.LINE_SEPARATOR + "" + BrowserCoreConstants.LINE_SEPARATOR
+
+ + "# Modify record" + BrowserCoreConstants.LINE_SEPARATOR + "dn: cn=modify record"
+ + BrowserCoreConstants.LINE_SEPARATOR + "changetype: modify" + BrowserCoreConstants.LINE_SEPARATOR + "add: cn"
+ + BrowserCoreConstants.LINE_SEPARATOR + "cn: modify record" + BrowserCoreConstants.LINE_SEPARATOR + "-"
+ + BrowserCoreConstants.LINE_SEPARATOR + "delete: cn" + BrowserCoreConstants.LINE_SEPARATOR + "-"
+ + BrowserCoreConstants.LINE_SEPARATOR + "replace: cn" + BrowserCoreConstants.LINE_SEPARATOR
+ + "cn: modify record" + BrowserCoreConstants.LINE_SEPARATOR + "-" + BrowserCoreConstants.LINE_SEPARATOR + ""
+ + BrowserCoreConstants.LINE_SEPARATOR
+
+ + "# Delete record" + BrowserCoreConstants.LINE_SEPARATOR + "dn: cn=delete record"
+ + BrowserCoreConstants.LINE_SEPARATOR + "changetype: delete" + BrowserCoreConstants.LINE_SEPARATOR + ""
+ + BrowserCoreConstants.LINE_SEPARATOR
+
+ + "# Modify DN record" + BrowserCoreConstants.LINE_SEPARATOR + "dn: cn=moddn record"
+ + BrowserCoreConstants.LINE_SEPARATOR + "changetype: moddn" + BrowserCoreConstants.LINE_SEPARATOR
+ + "newrdn: cn=new rdn" + BrowserCoreConstants.LINE_SEPARATOR + "deleteoldrdn: 1"
+ + BrowserCoreConstants.LINE_SEPARATOR + "newsuperior: cn=new superior" + BrowserCoreConstants.LINE_SEPARATOR
+ + "" + BrowserCoreConstants.LINE_SEPARATOR;
+
+ private LdifEditorWidget ldifEditorWidget;
+
+ private SyntaxItem[] syntaxItems;
+
+ private ColorSelector colorSelector;
+
+ private Button boldCheckBox;
+
+ private Button italicCheckBox;
+
+ private Button underlineCheckBox;
+
+ private Button strikethroughCheckBox;
+
+ private TableViewer syntaxItemViewer;
+
+ private class SyntaxItem
+ {
+ String displayName;
+
+ String key;
+
+ RGB rgb;
+
+ boolean bold;
+
+ boolean italic;
+
+ boolean strikethrough;
+
+ boolean underline;
+
+
+ SyntaxItem( String displayName, String key )
+ {
+ this.displayName = displayName;
+ this.key = key;
+ loadPreferences();
+ }
+
+
+ int getStyle()
+ {
+ int style = SWT.NORMAL;
+ if ( bold )
+ style |= SWT.BOLD;
+ if ( italic )
+ style |= SWT.ITALIC;
+ if ( strikethrough )
+ style |= TextAttribute.STRIKETHROUGH;
+ if ( underline )
+ style |= TextAttribute.UNDERLINE;
+ return style;
+ }
+
+
+ void setStyle( int style )
+ {
+ this.bold = ( style & SWT.BOLD ) != SWT.NORMAL;
+ this.italic = ( style & SWT.ITALIC ) != SWT.NORMAL;
+ this.strikethrough = ( style & TextAttribute.STRIKETHROUGH ) != SWT.NORMAL;
+ this.underline = ( style & TextAttribute.UNDERLINE ) != SWT.NORMAL;
+ }
+
+
+ void loadPreferences()
+ {
+ IPreferenceStore store = BrowserUIPlugin.getDefault().getPreferenceStore();
+ this.rgb = PreferenceConverter.getColor( store, key
+ + BrowserUIConstants.PREFERENCE_LDIFEDITOR_SYNTAX_RGB_SUFFIX );
+ int style = store.getInt( key + BrowserUIConstants.PREFERENCE_LDIFEDITOR_SYNTAX_STYLE_SUFFIX );
+ setStyle( style );
+ }
+
+
+ void savePreferences()
+ {
+ IPreferenceStore store = BrowserUIPlugin.getDefault().getPreferenceStore();
+ PreferenceConverter.setValue( store, key + BrowserUIConstants.PREFERENCE_LDIFEDITOR_SYNTAX_RGB_SUFFIX, rgb );
+ store.setValue( key + BrowserUIConstants.PREFERENCE_LDIFEDITOR_SYNTAX_STYLE_SUFFIX, getStyle() );
+ }
+
+
+ void loadDefaultPreferences()
+ {
+ IPreferenceStore store = BrowserUIPlugin.getDefault().getPreferenceStore();
+ this.rgb = PreferenceConverter.getDefaultColor( store, key
+ + BrowserUIConstants.PREFERENCE_LDIFEDITOR_SYNTAX_RGB_SUFFIX );
+ int style = store.getDefaultInt( key + BrowserUIConstants.PREFERENCE_LDIFEDITOR_SYNTAX_STYLE_SUFFIX );
+ setStyle( style );
+ }
+
+
+ public String toString()
+ {
+ return displayName;
+ }
+ }
+
+
+ public LdifEditorSyntaxColoringPreferencePage()
+ {
+ super( "Syntax Coloring" );
+ super.setPreferenceStore( BrowserUIPlugin.getDefault().getPreferenceStore() );
+ // super.setDescription("");
+ }
+
+
+ public void init( IWorkbench workbench )
+ {
+ }
+
+
+ public void dispose()
+ {
+ ldifEditorWidget.dispose();
+ super.dispose();
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ Composite composite = new Composite( parent, SWT.NONE );
+ GridLayout layout = new GridLayout( 1, false );
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.marginLeft = 0;
+ layout.marginRight = 0;
+ layout.marginTop = 0;
+ layout.marginBottom = 0;
+ composite.setLayout( layout );
+ GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+ composite.setLayoutData( gd );
+
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+
+ createSyntaxPage( composite );
+ createPreviewer( composite );
+
+ syntaxItems = new SyntaxItem[10];
+ syntaxItems[0] = new SyntaxItem( "Comments", BrowserUIConstants.PREFERENCE_LDIFEDITOR_SYNTAX_COMMENT );
+ syntaxItems[1] = new SyntaxItem( "DN", BrowserUIConstants.PREFERENCE_LDIFEDITOR_SYNTAX_DN );
+ syntaxItems[2] = new SyntaxItem( "Attribute Descriptions",
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_SYNTAX_ATTRIBUTE );
+ syntaxItems[3] = new SyntaxItem( "Value Types", BrowserUIConstants.PREFERENCE_LDIFEDITOR_SYNTAX_VALUETYPE );
+ syntaxItems[4] = new SyntaxItem( "Values", BrowserUIConstants.PREFERENCE_LDIFEDITOR_SYNTAX_VALUE );
+ syntaxItems[5] = new SyntaxItem( "Keywords (w/o changetypes)",
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_SYNTAX_KEYWORD );
+ syntaxItems[6] = new SyntaxItem( "Changetype 'add'",
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_SYNTAX_CHANGETYPEADD );
+ syntaxItems[7] = new SyntaxItem( "Changetype 'modify'",
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_SYNTAX_CHANGETYPEMODIFY );
+ syntaxItems[8] = new SyntaxItem( "Changetype 'delete'",
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_SYNTAX_CHANGETYPEDELETE );
+ syntaxItems[9] = new SyntaxItem( "Changetype 'moddn'",
+ BrowserUIConstants.PREFERENCE_LDIFEDITOR_SYNTAX_CHANGETYPEMODDN );
+ syntaxItemViewer.setInput( syntaxItems );
+ syntaxItemViewer.setSelection( new StructuredSelection( syntaxItems[0] ) );
+
+ return composite;
+ }
+
+
+ private void createSyntaxPage( Composite parent )
+ {
+
+ BaseWidgetUtils.createLabel( parent, "Element:", 1 );
+
+ Composite editorComposite = BaseWidgetUtils.createColumnContainer( parent, 2, 1 );
+
+ syntaxItemViewer = new TableViewer( editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER
+ | SWT.FULL_SELECTION );
+ syntaxItemViewer.setLabelProvider( new LabelProvider() );
+ syntaxItemViewer.setContentProvider( new ArrayContentProvider() );
+ // colorListViewer.setSorter(new WorkbenchViewerSorter());
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ gd.heightHint = convertHeightInCharsToPixels( 5 );
+ syntaxItemViewer.getControl().setLayoutData( gd );
+
+ Composite stylesComposite = BaseWidgetUtils.createColumnContainer( editorComposite, 1, 1 );
+ stylesComposite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ Composite colorComposite = BaseWidgetUtils.createColumnContainer( stylesComposite, 2, 1 );
+ BaseWidgetUtils.createLabel( colorComposite, "Color:", 1 );
+ colorSelector = new ColorSelector( colorComposite );
+ boldCheckBox = BaseWidgetUtils.createCheckbox( stylesComposite, "Bold", 1 );
+ italicCheckBox = BaseWidgetUtils.createCheckbox( stylesComposite, "Italic", 1 );
+ strikethroughCheckBox = BaseWidgetUtils.createCheckbox( stylesComposite, "Strikethrough", 1 );
+ underlineCheckBox = BaseWidgetUtils.createCheckbox( stylesComposite, "Underline", 1 );
+
+ syntaxItemViewer.addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ handleSyntaxItemViewerSelectionEvent();
+ }
+ } );
+ colorSelector.addListener( new IPropertyChangeListener()
+ {
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ handleColorSelectorEvent();
+ }
+ } );
+ boldCheckBox.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ handleBoldSelectionEvent();
+ }
+ } );
+ italicCheckBox.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ handleItalicSelectionEvent();
+ }
+ } );
+ strikethroughCheckBox.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ handleStrikethroughSelectionEvent();
+ }
+ } );
+ underlineCheckBox.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ handleUnderlineSelectionEvent();
+ }
+ } );
+
+ }
+
+
+ private void handleUnderlineSelectionEvent()
+ {
+ SyntaxItem item = getSyntaxItem();
+ if ( item != null )
+ {
+ item.underline = underlineCheckBox.getSelection();
+ setTextAttribute( item );
+ }
+ }
+
+
+ private void handleStrikethroughSelectionEvent()
+ {
+ SyntaxItem item = getSyntaxItem();
+ if ( item != null )
+ {
+ item.strikethrough = strikethroughCheckBox.getSelection();
+ setTextAttribute( item );
+ }
+ }
+
+
+ private void handleItalicSelectionEvent()
+ {
+ SyntaxItem item = getSyntaxItem();
+ if ( item != null )
+ {
+ item.italic = italicCheckBox.getSelection();
+ setTextAttribute( item );
+ }
+ }
+
+
+ private void handleBoldSelectionEvent()
+ {
+ SyntaxItem item = getSyntaxItem();
+ if ( item != null )
+ {
+ item.bold = boldCheckBox.getSelection();
+ setTextAttribute( item );
+ }
+ }
+
+
+ private void handleColorSelectorEvent()
+ {
+ SyntaxItem item = getSyntaxItem();
+ if ( item != null )
+ {
+ item.rgb = colorSelector.getColorValue();
+ setTextAttribute( item );
+ }
+ }
+
+
+ private void handleSyntaxItemViewerSelectionEvent()
+ {
+ SyntaxItem item = getSyntaxItem();
+ if ( item != null )
+ {
+ colorSelector.setColorValue( item.rgb );
+ boldCheckBox.setSelection( item.bold );
+ italicCheckBox.setSelection( item.italic );
+ strikethroughCheckBox.setSelection( item.strikethrough );
+ underlineCheckBox.setSelection( item.underline );
+ }
+ }
+
+
+ private SyntaxItem getSyntaxItem()
+ {
+ SyntaxItem item = ( SyntaxItem ) ( ( IStructuredSelection ) syntaxItemViewer.getSelection() ).getFirstElement();
+ return item;
+ }
+
+
+ private void setTextAttribute( SyntaxItem item )
+ {
+ ldifEditorWidget.getSourceViewerConfiguration().setTextAttribute( item.key, item.rgb, item.getStyle() );
+
+ int topIndex = ldifEditorWidget.getSourceViewer().getTopIndex();
+ // ldifEditorWidget.getSourceViewer().getDocument().set("");
+ ldifEditorWidget.getSourceViewer().getDocument().set( LDIF_INITIAL );
+ ldifEditorWidget.getSourceViewer().setTopIndex( topIndex );
+ }
+
+
+ private void createPreviewer( Composite parent )
+ {
+
+ BaseWidgetUtils.createLabel( parent, "Preview:", 1 );
+
+ ldifEditorWidget = new LdifEditorWidget( null, LDIF_INITIAL, false );
+ ldifEditorWidget.createWidget( parent );
+ ldifEditorWidget.getSourceViewer().setEditable( false );
+
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ gd.widthHint = convertWidthInCharsToPixels( 20 );
+ gd.heightHint = convertHeightInCharsToPixels( 5 );
+ ldifEditorWidget.getSourceViewer().getControl().setLayoutData( gd );
+
+ }
+
+
+ public IConnection getConnection()
+ {
+ return ldifEditorWidget.getConnection();
+ }
+
+
+ public LdifFile getLdifModel()
+ {
+ return ldifEditorWidget.getLdifModel();
+ }
+
+
+ public boolean performOk()
+ {
+ for ( int i = 0; i < syntaxItems.length; i++ )
+ {
+ syntaxItems[i].savePreferences();
+ }
+ return true;
+ }
+
+
+ protected void performDefaults()
+ {
+ for ( int i = 0; i < syntaxItems.length; i++ )
+ {
+ syntaxItems[i].loadDefaultPreferences();
+ setTextAttribute( syntaxItems[i] );
+ }
+ handleSyntaxItemViewerSelectionEvent();
+ super.performDefaults();
+ }
+
+
+ public Object getAdapter( Class adapter )
+ {
+ return null;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/LdifEditorTemplatesPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/LdifEditorTemplatesPreferencePage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/LdifEditorTemplatesPreferencePage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/preferences/LdifEditorTemplatesPreferencePage.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.dialogs.preferences;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.eclipse.ui.texteditor.templates.TemplatePreferencePage;
+
+
+public class LdifEditorTemplatesPreferencePage extends TemplatePreferencePage
+{
+
+ public LdifEditorTemplatesPreferencePage()
+ {
+ super();
+ super.setPreferenceStore( BrowserUIPlugin.getDefault().getPreferenceStore() );
+ super.setTemplateStore( BrowserUIPlugin.getDefault().getLdifTemplateStore() );
+ super.setContextTypeRegistry( BrowserUIPlugin.getDefault().getLdifTemplateContextTypeRegistry() );
+ }
+
+}