You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2007/11/05 18:01:46 UTC
svn commit: r592087 [4/16] - in
/directory/sandbox/felixk/studio-ldapbrowser-ui: ./ META-INF/ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/directory/
src/main/java/org/apache/directory/studio/ src/...
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/AttributePropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/AttributePropertyPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/AttributePropertyPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/AttributePropertyPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,254 @@
+/*
+ * 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.studio.ldapbrowser.ui.dialogs.properties;
+
+
+import java.util.Arrays;
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.AttributeTypeDescription;
+import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.Text;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+
+public class AttributePropertyPage extends PropertyPage implements IWorkbenchPropertyPage
+{
+
+ private Text attributeNameText;
+
+ private Text attributeTypeText;
+
+ private Text attributeValuesText;
+
+ private Text attributeSizeText;
+
+ private Text atdOidText;
+
+ private Text atdNamesText;
+
+ private Text atdDescText;
+
+ private Text atdUsageText;
+
+ private Button singleValuedFlag;
+
+ private Button collectiveFlag;
+
+ private Button obsoleteFlag;
+
+ private Button noUserModificationFlag;
+
+ private Text equalityMatchingRuleText;
+
+ private Text substringMatchingRuleText;
+
+ private Text orderingMatchingRuleText;
+
+ private Text syntaxOidText;
+
+ private Text syntaxDescText;
+
+ private Text syntaxLengthText;
+
+
+ public AttributePropertyPage()
+ {
+ super();
+ super.noDefaultAndApplyButton();
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
+
+ Composite mainGroup = BaseWidgetUtils.createColumnContainer( composite, 2, 1 );
+
+ BaseWidgetUtils.createLabel( mainGroup, "Description:", 1 );
+ attributeNameText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 );
+
+ BaseWidgetUtils.createLabel( mainGroup, "Type:", 1 );
+ attributeTypeText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 );
+
+ BaseWidgetUtils.createLabel( mainGroup, "Number of Values:", 1 );
+ attributeValuesText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 );
+
+ BaseWidgetUtils.createLabel( mainGroup, "Attribute Size:", 1 );
+ attributeSizeText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 );
+
+ Group atdGroup = BaseWidgetUtils.createGroup( composite, "Attribute Type", 1 );
+ Composite atdComposite = BaseWidgetUtils.createColumnContainer( atdGroup, 2, 1 );
+
+ BaseWidgetUtils.createLabel( atdComposite, "Numeric OID:", 1 );
+ atdOidText = BaseWidgetUtils.createLabeledText( atdComposite, "", 1 );
+
+ BaseWidgetUtils.createLabel( atdComposite, "Alternative Names:", 1 );
+ atdNamesText = BaseWidgetUtils.createLabeledText( atdComposite, "", 1 );
+
+ BaseWidgetUtils.createLabel( atdComposite, "Description:", 1 );
+ atdDescText = BaseWidgetUtils.createWrappedLabeledText( atdComposite, "", 1 );
+
+ BaseWidgetUtils.createLabel( atdComposite, "Usage:", 1 );
+ atdUsageText = BaseWidgetUtils.createLabeledText( atdComposite, "", 1 );
+
+ Group flagsGroup = BaseWidgetUtils.createGroup( composite, "Flags", 1 );
+ Composite flagsComposite = BaseWidgetUtils.createColumnContainer( flagsGroup, 4, 1 );
+
+ singleValuedFlag = BaseWidgetUtils.createCheckbox( flagsComposite, "Single valued", 1 );
+ singleValuedFlag.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ singleValuedFlag.setSelection( !singleValuedFlag.getSelection() );
+ }
+ } );
+
+ noUserModificationFlag = BaseWidgetUtils.createCheckbox( flagsComposite, "Read only", 1 );
+ noUserModificationFlag.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ noUserModificationFlag.setSelection( !noUserModificationFlag.getSelection() );
+ }
+ } );
+
+ collectiveFlag = BaseWidgetUtils.createCheckbox( flagsComposite, "Collective", 1 );
+ collectiveFlag.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ collectiveFlag.setSelection( !collectiveFlag.getSelection() );
+ }
+ } );
+
+ obsoleteFlag = BaseWidgetUtils.createCheckbox( flagsComposite, "Obsolete", 1 );
+ obsoleteFlag.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ obsoleteFlag.setSelection( !obsoleteFlag.getSelection() );
+ }
+ } );
+
+ Group syntaxGroup = BaseWidgetUtils.createGroup( composite, "Syntax", 1 );
+ Composite syntaxComposite = BaseWidgetUtils.createColumnContainer( syntaxGroup, 2, 1 );
+
+ BaseWidgetUtils.createLabel( syntaxComposite, "Syntax OID:", 1 );
+ syntaxOidText = BaseWidgetUtils.createLabeledText( syntaxComposite, "", 1 );
+
+ BaseWidgetUtils.createLabel( syntaxComposite, "Syntax Description:", 1 );
+ syntaxDescText = BaseWidgetUtils.createLabeledText( syntaxComposite, "", 1 );
+
+ BaseWidgetUtils.createLabel( syntaxComposite, "Syntax Length:", 1 );
+ syntaxLengthText = BaseWidgetUtils.createLabeledText( syntaxComposite, "", 1 );
+
+ Group matchingGroup = BaseWidgetUtils.createGroup( composite, "Matching Rules", 1 );
+ Composite matchingComposite = BaseWidgetUtils.createColumnContainer( matchingGroup, 2, 1 );
+
+ BaseWidgetUtils.createLabel( matchingComposite, "Equality Match:", 1 );
+ equalityMatchingRuleText = BaseWidgetUtils.createLabeledText( matchingComposite, "", 1 );
+
+ BaseWidgetUtils.createLabel( matchingComposite, "Substring Match:", 1 );
+ substringMatchingRuleText = BaseWidgetUtils.createLabeledText( matchingComposite, "", 1 );
+
+ BaseWidgetUtils.createLabel( matchingComposite, "Ordering Match:", 1 );
+ orderingMatchingRuleText = BaseWidgetUtils.createLabeledText( matchingComposite, "", 1 );
+
+ IAttribute attribute = getAttribute( getElement() );
+ if ( attribute != null )
+ {
+
+ int bytes = 0;
+ int valCount = 0;
+ IValue[] allValues = attribute.getValues();
+ for ( int valIndex = 0; valIndex < allValues.length; valIndex++ )
+ {
+ if ( !allValues[valIndex].isEmpty() )
+ {
+ valCount++;
+ bytes += allValues[valIndex].getBinaryValue().length;
+ }
+ }
+
+ this.setMessage( "Attribute " + attribute.getDescription() );
+ attributeNameText.setText( attribute.getDescription() );
+ attributeTypeText.setText( attribute.isString() ? "String" : "Binary" );
+ attributeValuesText.setText( "" + valCount );
+ attributeSizeText.setText( Utils.formatBytes( bytes ) );
+
+ if ( attribute.getEntry().getBrowserConnection().getSchema().hasAttributeTypeDescription(
+ attribute.getDescription() ) )
+ {
+ AttributeTypeDescription atd = attribute.getEntry().getBrowserConnection().getSchema()
+ .getAttributeTypeDescription( attribute.getDescription() );
+
+ atdOidText.setText( atd.getNumericOID() );
+ String atdNames = Arrays.asList( atd.getNames() ).toString();
+ atdNamesText.setText( atdNames.substring( 1, atdNames.length() - 1 ) );
+ atdDescText.setText( Utils.getNonNullString( atd.getDesc() ) );
+ atdUsageText.setText( Utils.getNonNullString( atd.getUsage() ) );
+
+ singleValuedFlag.setSelection( atd.isSingleValued() );
+ noUserModificationFlag.setSelection( atd.isNoUserModification() );
+ collectiveFlag.setSelection( atd.isCollective() );
+ obsoleteFlag.setSelection( atd.isObsolete() );
+
+ syntaxOidText.setText( Utils.getNonNullString( atd.getSyntaxDescriptionNumericOIDTransitive() ) );
+ syntaxDescText.setText( Utils.getNonNullString( atd.getSyntaxDescription().getDesc() ) );
+ syntaxLengthText.setText( Utils.getNonNullString( atd.getSyntaxDescriptionLengthTransitive() ) );
+
+ equalityMatchingRuleText.setText( Utils.getNonNullString( atd
+ .getEqualityMatchingRuleDescriptionOIDTransitive() ) );
+ substringMatchingRuleText.setText( Utils.getNonNullString( atd
+ .getSubstringMatchingRuleDescriptionOIDTransitive() ) );
+ orderingMatchingRuleText.setText( Utils.getNonNullString( atd
+ .getOrderingMatchingRuleDescriptionOIDTransitive() ) );
+ }
+ }
+
+ return parent;
+ }
+
+
+ private static IAttribute getAttribute( Object element )
+ {
+ IAttribute attribute = null;
+ if ( element instanceof IAdaptable )
+ {
+ attribute = ( IAttribute ) ( ( IAdaptable ) element ).getAdapter( IAttribute.class );
+ }
+ return attribute;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/AttributePropertyPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/BookmarkPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/BookmarkPropertyPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/BookmarkPropertyPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/BookmarkPropertyPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,158 @@
+/*
+ * 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.studio.ldapbrowser.ui.dialogs.properties;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.apache.directory.studio.ldapbrowser.common.widgets.search.EntryWidget;
+import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
+import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+
+public class BookmarkPropertyPage extends PropertyPage implements IWorkbenchPropertyPage
+{
+
+ private IBookmark bookmark;
+
+ private Text bookmarkNameText;
+
+ private EntryWidget bookmarkEntryWidget;
+
+
+ public BookmarkPropertyPage()
+ {
+ super();
+ super.noDefaultAndApplyButton();
+ }
+
+
+ public void dispose()
+ {
+ super.dispose();
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ if ( getElement() instanceof IAdaptable )
+ {
+ this.bookmark = ( IBookmark ) ( ( IAdaptable ) getElement() ).getAdapter( IBookmark.class );
+ super.setMessage( "Bookmark " + Utils.shorten( bookmark.getName(), 30 ) );
+ }
+ else
+ {
+ this.bookmark = null;
+ }
+
+ Composite innerComposite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
+
+ BaseWidgetUtils.createLabel( innerComposite, "Bookmark Name:", 1 );
+ this.bookmarkNameText = BaseWidgetUtils.createText( innerComposite, this.bookmark != null ? this.bookmark
+ .getName() : "", 2 );
+ this.bookmarkNameText.setFocus();
+ this.bookmarkNameText.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ validate();
+ }
+ } );
+
+ BaseWidgetUtils.createLabel( innerComposite, "Bookmark DN:", 1 );
+ this.bookmarkEntryWidget = new EntryWidget();
+ this.bookmarkEntryWidget.createWidget( innerComposite );
+ if ( this.bookmark != null )
+ {
+ this.bookmarkEntryWidget.setInput( this.bookmark.getBrowserConnection(), this.bookmark.getDn() );
+ }
+ this.bookmarkEntryWidget.addWidgetModifyListener( new WidgetModifyListener()
+ {
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ validate();
+ }
+ } );
+
+ return innerComposite;
+ }
+
+
+ public boolean performOk()
+ {
+ if ( this.bookmark != null )
+ {
+ this.bookmark.setName( this.bookmarkNameText.getText() );
+ this.bookmark.setDn( this.bookmarkEntryWidget.getDn() );
+ this.bookmarkEntryWidget.saveDialogSettings();
+ }
+
+ return true;
+ }
+
+
+ private void validate()
+ {
+
+ setValid( this.bookmarkEntryWidget.getDn() != null && !"".equals( this.bookmarkNameText.getText() ) );
+
+ if ( this.bookmark != null )
+ {
+ if ( this.bookmarkEntryWidget.getDn() == null )
+ {
+ setValid( false );
+ setErrorMessage( "Please enter a DN." );
+ }
+ else if ( "".equals( this.bookmarkNameText.getText() ) )
+ {
+ setValid( false );
+ setErrorMessage( "Please enter a name." );
+ }
+ else if ( !bookmark.getName().equals( this.bookmarkNameText.getText() )
+ && bookmark.getBrowserConnection().getBookmarkManager().getBookmark( this.bookmarkNameText.getText() ) != null )
+ {
+ setValid( false );
+ setErrorMessage( "A bookmark with this name already exists." );
+ }
+ else
+ {
+ setValid( true );
+ setErrorMessage( null );
+ }
+ }
+ else
+ {
+ setValid( false );
+ }
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/BookmarkPropertyPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/EntryPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/EntryPropertyPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/EntryPropertyPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/EntryPropertyPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,305 @@
+/*
+ * 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.studio.ldapbrowser.ui.dialogs.properties;
+
+
+import org.apache.directory.studio.ldapbrowser.common.jobs.RunnableContextJobAdapter;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent;
+import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeAttributesJob;
+import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeChildrenJob;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+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.Group;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+
+public class EntryPropertyPage extends PropertyPage implements IWorkbenchPropertyPage
+{
+
+ private Text dnText;
+
+ private Text urlText;
+
+ private Text ctText;
+
+ private Text cnText;
+
+ private Text mtText;
+
+ private Text mnText;
+
+ private Button reloadCmiButton;
+
+ private Text sizeText;
+
+ private Text childrenText;
+
+ private Text attributesText;
+
+ private Text valuesText;
+
+ private Button includeOperationalAttributesButton;
+
+ private Button reloadEntryButton;
+
+
+ public EntryPropertyPage()
+ {
+ super();
+ super.noDefaultAndApplyButton();
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
+
+ Composite mainGroup = BaseWidgetUtils.createColumnContainer( BaseWidgetUtils.createColumnContainer( composite,
+ 1, 1 ), 2, 1 );
+ BaseWidgetUtils.createLabel( mainGroup, "DN:", 1 );
+ dnText = BaseWidgetUtils.createWrappedLabeledText( mainGroup, "", 1 );
+ BaseWidgetUtils.createLabel( mainGroup, "URL:", 1 );
+ urlText = BaseWidgetUtils.createWrappedLabeledText( mainGroup, "", 1 );
+
+ Group cmiGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ),
+ "Create and Modify Information", 1 );
+ Composite cmiComposite = BaseWidgetUtils.createColumnContainer( cmiGroup, 3, 1 );
+
+ BaseWidgetUtils.createLabel( cmiComposite, "Create Timestamp:", 1 );
+ ctText = BaseWidgetUtils.createLabeledText( cmiComposite, "", 2 );
+
+ BaseWidgetUtils.createLabel( cmiComposite, "Creators Name:", 1 );
+ cnText = BaseWidgetUtils.createLabeledText( cmiComposite, "", 2 );
+
+ BaseWidgetUtils.createLabel( cmiComposite, "Modify Timestamp:", 1 );
+ mtText = BaseWidgetUtils.createLabeledText( cmiComposite, "", 2 );
+
+ BaseWidgetUtils.createLabel( cmiComposite, "Modifiers Name:", 1 );
+ mnText = BaseWidgetUtils.createLabeledText( cmiComposite, "", 1 );
+
+ reloadCmiButton = BaseWidgetUtils.createButton( cmiComposite, "", 1 );
+ GridData gd = new GridData();
+ gd.verticalAlignment = SWT.BOTTOM;
+ gd.horizontalAlignment = SWT.RIGHT;
+ reloadCmiButton.setLayoutData( gd );
+ reloadCmiButton.addSelectionListener( new SelectionListener()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ reloadOperationalAttributes();
+ }
+
+
+ public void widgetDefaultSelected( SelectionEvent e )
+ {
+ }
+ } );
+
+ Group sizingGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ),
+ "Sizing Information", 1 );
+ Composite sizingComposite = BaseWidgetUtils.createColumnContainer( sizingGroup, 3, 1 );
+
+ BaseWidgetUtils.createLabel( sizingComposite, "Entry Size:", 1 );
+ sizeText = BaseWidgetUtils.createLabeledText( sizingComposite, "", 2 );
+
+ BaseWidgetUtils.createLabel( sizingComposite, "Number of Children:", 1 );
+ childrenText = BaseWidgetUtils.createLabeledText( sizingComposite, "", 2 );
+
+ BaseWidgetUtils.createLabel( sizingComposite, "Number of Attributes:", 1 );
+ attributesText = BaseWidgetUtils.createLabeledText( sizingComposite, "", 2 );
+
+ BaseWidgetUtils.createLabel( sizingComposite, "Number of Values:", 1 );
+ valuesText = BaseWidgetUtils.createLabeledText( sizingComposite, "", 2 );
+
+ includeOperationalAttributesButton = BaseWidgetUtils.createCheckbox( sizingComposite,
+ "Include operational attributes", 2 );
+ includeOperationalAttributesButton.addSelectionListener( new SelectionListener()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ entryUpdated( getEntry( getElement() ) );
+ }
+
+
+ public void widgetDefaultSelected( SelectionEvent e )
+ {
+ }
+ } );
+
+ reloadEntryButton = BaseWidgetUtils.createButton( sizingComposite, "", 1 );
+ gd = new GridData();
+ gd.verticalAlignment = SWT.BOTTOM;
+ gd.horizontalAlignment = SWT.RIGHT;
+ reloadEntryButton.setLayoutData( gd );
+ reloadEntryButton.addSelectionListener( new SelectionListener()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ reloadEntry();
+ }
+
+
+ public void widgetDefaultSelected( SelectionEvent e )
+ {
+ }
+ } );
+
+ this.entryUpdated( getEntry( getElement() ) );
+
+ return composite;
+ }
+
+
+ private void reloadOperationalAttributes()
+ {
+ IEntry entry = EntryPropertyPage.getEntry( getElement() );
+ InitializeAttributesJob job = new InitializeAttributesJob( new IEntry[]
+ { entry }, true );
+ RunnableContextJobAdapter.execute( job );
+
+ this.entryUpdated( entry );
+ }
+
+
+ private void reloadEntry()
+ {
+ IEntry entry = EntryPropertyPage.getEntry( getElement() );
+ InitializeChildrenJob job1 = new InitializeChildrenJob( new IEntry[]
+ { entry } );
+ InitializeAttributesJob job2 = new InitializeAttributesJob( new IEntry[]
+ { entry }, true );
+ RunnableContextJobAdapter.execute( job1 );
+ RunnableContextJobAdapter.execute( job2 );
+ this.entryUpdated( entry );
+ }
+
+
+ static IEntry getEntry( Object element )
+ {
+ IEntry entry = null;
+ if ( element instanceof IAdaptable )
+ {
+ entry = ( IEntry ) ( ( IAdaptable ) element ).getAdapter( IEntry.class );
+ }
+ return entry;
+ }
+
+
+ public boolean isDisposed()
+ {
+ return this.dnText.isDisposed();
+ }
+
+
+ public void entryUpdated( EntryModificationEvent event )
+ {
+ this.entryUpdated( event.getModifiedEntry() );
+ }
+
+
+ private String getNonNullStringValue( IAttribute att )
+ {
+ String value = null;
+ if ( att != null )
+ {
+ value = att.getStringValue();
+ }
+ return value != null ? value : "-";
+ }
+
+
+ private void entryUpdated( IEntry entry )
+ {
+
+ if ( !this.dnText.isDisposed() )
+ {
+
+ this.setMessage( "Entry " + entry.getDn().getUpName() );
+
+ this.dnText.setText( entry.getDn().getUpName() );
+ this.urlText.setText( entry.getUrl().toString() );
+ this.ctText.setText( getNonNullStringValue( entry
+ .getAttribute( IAttribute.OPERATIONAL_ATTRIBUTE_CREATE_TIMESTAMP ) ) );
+ this.cnText.setText( getNonNullStringValue( entry
+ .getAttribute( IAttribute.OPERATIONAL_ATTRIBUTE_CREATORS_NAME ) ) );
+ this.mtText.setText( getNonNullStringValue( entry
+ .getAttribute( IAttribute.OPERATIONAL_ATTRIBUTE_MODIFY_TIMESTAMP ) ) );
+ this.mnText.setText( getNonNullStringValue( entry
+ .getAttribute( IAttribute.OPERATIONAL_ATTRIBUTE_MODIFIERS_NAME ) ) );
+ this.reloadCmiButton.setText( "Refresh" );
+
+ int attCount = 0;
+ int valCount = 0;
+ int bytes = 0;
+
+ IAttribute[] allAttributes = entry.getAttributes();
+ if ( allAttributes != null )
+ {
+ for ( int attIndex = 0; attIndex < allAttributes.length; attIndex++ )
+ {
+ if ( !allAttributes[attIndex].isOperationalAttribute()
+ || this.includeOperationalAttributesButton.getSelection() )
+ {
+ attCount++;
+ IValue[] allValues = allAttributes[attIndex].getValues();
+ for ( int valIndex = 0; valIndex < allValues.length; valIndex++ )
+ {
+ if ( !allValues[valIndex].isEmpty() )
+ {
+ valCount++;
+ bytes += allValues[valIndex].getBinaryValue().length;
+ }
+ }
+ }
+ }
+ }
+
+ this.reloadEntryButton.setText( "Refresh" );
+ if ( !entry.isChildrenInitialized() )
+ {
+ this.childrenText.setText( "Not checked" );
+ }
+ else
+ {
+ this.childrenText.setText( "" + entry.getChildrenCount()
+ + ( entry.hasMoreChildren() ? " fetched, may have more" : "" ) );
+ }
+ this.attributesText.setText( "" + attCount );
+ this.valuesText.setText( "" + valCount );
+ this.sizeText.setText( Utils.formatBytes( bytes ) );
+ }
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/EntryPropertyPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/RootDSEPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/RootDSEPropertyPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/RootDSEPropertyPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/RootDSEPropertyPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,573 @@
+/*
+ * 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.studio.ldapbrowser.ui.dialogs.properties;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetTableMetadata;
+import org.apache.directory.studio.ldapbrowser.core.BrowserConnectionManager;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.IRootDSE;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.RootDSE;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowData;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+
+public class RootDSEPropertyPage extends PropertyPage implements IWorkbenchPropertyPage
+{
+
+ private TabFolder tabFolder;
+
+ private TabItem commonsTab;
+
+ private TabItem controlsTab;
+
+ private TabItem extensionsTab;
+
+ private TabItem featuresTab;
+
+ private TabItem rawTab;
+
+ public static ResourceBundle oidDescriptions = null;
+ // Load RessourceBundle with OID descriptions
+ static
+ {
+ try
+ {
+ oidDescriptions = ResourceBundle
+ .getBundle( "org.apache.directory.studio.ldapbrowser.ui.dialogs.properties.OIDDescriptions" );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+
+ public RootDSEPropertyPage()
+ {
+ super();
+ super.noDefaultAndApplyButton();
+ }
+
+
+ static IBrowserConnection getConnection( Object element )
+ {
+ IBrowserConnection browserConnection = null;
+ if ( element instanceof IAdaptable )
+ {
+ browserConnection = ( IBrowserConnection ) ( ( IAdaptable ) element ).getAdapter( IBrowserConnection.class );
+ if(browserConnection == null)
+ {
+ Connection connection = ( Connection ) ( ( IAdaptable ) element ).getAdapter( Connection.class );
+ browserConnection = BrowserCorePlugin.getDefault().getConnectionManager().getBrowserConnection( connection );
+ }
+ }
+ return browserConnection;
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ final IBrowserConnection connection = getConnection( getElement() );
+
+ this.tabFolder = new TabFolder( parent, SWT.TOP );
+ RowLayout mainLayout = new RowLayout();
+ mainLayout.fill = true;
+ mainLayout.marginWidth = 0;
+ mainLayout.marginHeight = 0;
+ this.tabFolder.setLayout( mainLayout );
+
+ Composite composite = new Composite( this.tabFolder, SWT.NONE );
+ GridLayout gl = new GridLayout( 2, false );
+ composite.setLayout( gl );
+ BaseWidgetUtils.createLabel( composite, "Directory Type:", 1 );
+ Text typeText = BaseWidgetUtils.createLabeledText( composite, "-", 1 );
+ if ( connection != null && connection.getRootDSE() != null )
+ {
+ // Try to detect LDAP server from RootDSE
+ //
+ IRootDSE rootDSE = connection.getRootDSE();
+ String type = detectOpenLDAP( rootDSE );
+ if ( type == null )
+ {
+ type = detectSiemensDirX( rootDSE );
+ if ( type == null )
+ {
+ type = detectActiveDirectory( rootDSE );
+ if ( type == null )
+ {
+ type = detectByVendorName( rootDSE );
+ }
+ }
+ }
+
+ if ( type != null )
+ {
+ typeText.setText( type );
+ }
+ }
+ addInfo( connection, composite, "vendorName", "Vendor Name:" );
+ addInfo( connection, composite, "vendorVersion", "Vendor Version:" );
+ addInfo( connection, composite, "supportedLDAPVersion", "Supported LDAP Versions:" );
+ addInfo( connection, composite, "supportedSASLMechanisms", "Supported SASL Mechanisms:" );
+
+ this.commonsTab = new TabItem( this.tabFolder, SWT.NONE );
+ this.commonsTab.setText( "Info" );
+ this.commonsTab.setControl( composite );
+
+ // naming contexts
+ // alt servers
+ // schema DN
+ // ldap version
+
+ Composite controlsComposite = new Composite( this.tabFolder, SWT.NONE );
+ controlsComposite.setLayoutData( new RowData( 10, 10 ) );
+ GridLayout controlsLayout = new GridLayout();
+ controlsComposite.setLayout( controlsLayout );
+ ListViewer controlsViewer = new ListViewer( controlsComposite );
+ controlsViewer.getList().setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ controlsViewer.setContentProvider( new ArrayContentProvider() );
+ controlsViewer.setLabelProvider( new LabelProvider() );
+ if ( connection != null && connection.getRootDSE() != null )
+ {
+ String[] supportedControls = ( ( RootDSE ) connection.getRootDSE() ).getSupportedControls();
+ addDescritionsToOIDs( supportedControls );
+ controlsViewer.setInput( supportedControls );
+ }
+ this.controlsTab = new TabItem( this.tabFolder, SWT.NONE );
+ this.controlsTab.setText( "Controls" );
+ this.controlsTab.setControl( controlsComposite );
+
+ Composite extensionComposite = new Composite( this.tabFolder, SWT.NONE );
+ extensionComposite.setLayoutData( new RowData( 10, 10 ) );
+ GridLayout extensionLayout = new GridLayout();
+ extensionComposite.setLayout( extensionLayout );
+ ListViewer extensionViewer = new ListViewer( extensionComposite );
+ extensionViewer.getList().setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ extensionViewer.setContentProvider( new ArrayContentProvider() );
+ extensionViewer.setLabelProvider( new LabelProvider() );
+ if ( connection != null && connection.getRootDSE() != null )
+ {
+ String[] supportedExtensions = ( ( RootDSE ) connection.getRootDSE() ).getSupportedExtensions();
+ addDescritionsToOIDs( supportedExtensions );
+ extensionViewer.setInput( supportedExtensions );
+ }
+ this.extensionsTab = new TabItem( this.tabFolder, SWT.NONE );
+ this.extensionsTab.setText( "Extensions" );
+ this.extensionsTab.setControl( extensionComposite );
+
+ Composite featureComposite = new Composite( this.tabFolder, SWT.NONE );
+ featureComposite.setLayoutData( new RowData( 10, 10 ) );
+ GridLayout featureLayout = new GridLayout();
+ featureComposite.setLayout( featureLayout );
+ ListViewer featureViewer = new ListViewer( featureComposite );
+ featureViewer.getList().setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ featureViewer.setContentProvider( new ArrayContentProvider() );
+ featureViewer.setLabelProvider( new LabelProvider() );
+ if ( connection != null && connection.getRootDSE() != null )
+ {
+ String[] supportedFeatures = ( ( RootDSE ) connection.getRootDSE() ).getSupportedFeatures();
+ addDescritionsToOIDs( supportedFeatures );
+ featureViewer.setInput( supportedFeatures );
+ }
+ this.featuresTab = new TabItem( this.tabFolder, SWT.NONE );
+ this.featuresTab.setText( "Features" );
+ this.featuresTab.setControl( featureComposite );
+
+ Composite rawComposite = new Composite( this.tabFolder, SWT.NONE );
+ rawComposite.setLayoutData( new RowData( 10, 10 ) );
+ GridLayout rawLayout = new GridLayout();
+ rawComposite.setLayout( rawLayout );
+ Table table = new Table( rawComposite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
+ | SWT.FULL_SELECTION | SWT.HIDE_SELECTION );
+ GridData gridData = new GridData( GridData.FILL_BOTH );
+ table.setLayoutData( gridData );
+ table.setHeaderVisible( true );
+ table.setLinesVisible( true );
+ TableViewer viewer = new TableViewer( table );
+ for ( int i = 0; i < EntryEditorWidgetTableMetadata.COLUM_NAMES.length; i++ )
+ {
+ TableColumn column = new TableColumn( table, SWT.LEFT, i );
+ column.setText( EntryEditorWidgetTableMetadata.COLUM_NAMES[i] );
+ column.setWidth( 150 );
+ column.setResizable( true );
+ }
+ viewer.setColumnProperties( EntryEditorWidgetTableMetadata.COLUM_NAMES );
+ viewer.setSorter( new InnerViewerSorter() );
+ viewer.setContentProvider( new InnerContentProvider() );
+ viewer.setLabelProvider( new InnerLabelProvider() );
+ if ( connection != null )
+ {
+ IEntry entry = connection.getRootDSE();
+ viewer.setInput( entry );
+ }
+ this.rawTab = new TabItem( this.tabFolder, SWT.NONE );
+ this.rawTab.setText( "Raw" );
+ this.rawTab.setControl( rawComposite );
+
+ // setControl(composite);
+ return this.tabFolder;
+ }
+
+
+ /** Check various LDAP servers via vendorName attribute.
+ *
+ * @param rootDSE
+ */
+ private String detectByVendorName( IRootDSE rootDSE )
+ {
+
+ String result = null;
+
+ IAttribute vnAttribute = rootDSE.getAttribute( "vendorName" );
+ IAttribute vvAttribute = rootDSE.getAttribute( "vendorVersion" );
+
+ if ( vnAttribute != null && vnAttribute.getStringValues().length > 0 && vvAttribute != null
+ && vvAttribute.getStringValues().length > 0 )
+ {
+ if ( vnAttribute.getStringValues()[0].indexOf( "Apache Software Foundation" ) > -1 )
+ {
+ result = "Apache Directory Server";
+ }
+ if ( vnAttribute.getStringValues()[0].indexOf( "Novell" ) > -1
+ || vvAttribute.getStringValues()[0].indexOf( "eDirectory" ) > -1 )
+ {
+ result = "Novell eDirectory";
+ }
+ if ( vnAttribute.getStringValues()[0].indexOf( "Sun" ) > -1
+ || vvAttribute.getStringValues()[0].indexOf( "Sun" ) > -1 )
+ {
+ result = "Sun Directory Server";
+ }
+ if ( vnAttribute.getStringValues()[0].indexOf( "Netscape" ) > -1
+ || vvAttribute.getStringValues()[0].indexOf( "Netscape" ) > -1 )
+ {
+ result = "Netscape Directory Server";
+ }
+ if ( vnAttribute.getStringValues()[0].indexOf( "International Business Machines" ) > -1
+ && ( ( vvAttribute.getStringValues()[0].indexOf( "6.0" ) > -1 ) || ( vvAttribute.getStringValues()[0]
+ .indexOf( "5.2" ) > -1 ) ) )
+ {
+ result = "IBM Tivoli Directory Server";
+ }
+ }
+
+ return result;
+ }
+
+
+ /**
+ * Tries to detect a Microsoft Active Directory.
+ *
+ * @param rootDSE
+ * @return name of directory type, or null if no Active Directory server server was detected
+ */
+ private String detectActiveDirectory( IRootDSE rootDSE )
+ {
+
+ String result = null;
+
+ // check active directory
+ IAttribute rdncAttribute = rootDSE.getAttribute( "rootDomainNamingContext" );
+ if ( rdncAttribute != null )
+ {
+ IAttribute ffAttribute = rootDSE.getAttribute( "forestFunctionality" );
+ if ( ffAttribute != null )
+ {
+ result = "Microsoft Active Directory 2003";
+ }
+ else
+ {
+ result = "Microsoft Active Directory 2000";
+ }
+ }
+
+ return result;
+ }
+
+
+ /**
+ * Tries to detect a Siemens DirX server.
+ *
+ * @param rootDSE
+ * @return name of directory type, or null if no DirX server server was detected
+ */
+ private String detectSiemensDirX( IRootDSE rootDSE )
+ {
+
+ String result = null;
+
+ IAttribute ssseAttribute = rootDSE.getAttribute( "subSchemaSubentry" );
+ if ( ssseAttribute != null )
+ {
+ for ( int i = 0; i < ssseAttribute.getStringValues().length; i++ )
+ {
+ if ( "cn=LDAPGlobalSchemaSubentry".equals( ssseAttribute.getStringValues()[i] ) )
+ {
+ result = "Siemens DirX";
+ }
+ }
+ }
+
+ return result;
+ }
+
+
+ /**
+ * Tries to detect an OpenLDAP server
+ *
+ * @param rootDSE
+ * @return name (and sometimes version) of directory type, or null if no OpenLDAP server was detected
+ */
+ private String detectOpenLDAP( IRootDSE rootDSE )
+ {
+
+ String result = null;
+ boolean typeDetected = false;
+
+ // check OpenLDAP
+ IAttribute ocAttribute = rootDSE.getAttribute( "objectClass" );
+ if ( ocAttribute != null )
+ {
+ for ( int i = 0; i < ocAttribute.getStringValues().length; i++ )
+ {
+ if ( "OpenLDAProotDSE".equals( ocAttribute.getStringValues()[i] ) )
+ {
+ IAttribute ccAttribute = rootDSE.getAttribute( "configContext" );
+ if ( ccAttribute != null )
+ {
+ result = "OpenLDAP 2.3";
+ typeDetected = true;
+ }
+ if ( !typeDetected )
+ {
+ IAttribute scAttribute = rootDSE.getAttribute( "supportedControl" );
+ if ( scAttribute != null )
+ {
+ for ( int sci = 0; sci < scAttribute.getStringValues().length; sci++ )
+ {
+ // if("1.2.840.113556.1.4.319".equals(scAttribute.getStringValues()[sci]))
+ // {
+ if ( "2.16.840.1.113730.3.4.18".equals( scAttribute.getStringValues()[sci] ) )
+ {
+ result = "OpenLDAP 2.2";
+ typeDetected = true;
+ }
+ }
+ }
+
+ }
+ if ( !typeDetected )
+ {
+ IAttribute seAttribute = rootDSE.getAttribute( "supportedExtension" );
+ if ( seAttribute != null )
+ {
+ for ( int sei = 0; sei < seAttribute.getStringValues().length; sei++ )
+ {
+ if ( "1.3.6.1.4.1.4203.1.11.3".equals( seAttribute.getStringValues()[sei] ) )
+ {
+ result = "OpenLDAP 2.1";
+ typeDetected = true;
+ }
+ }
+ }
+ }
+ if ( !typeDetected )
+ {
+ IAttribute sfAttribute = rootDSE.getAttribute( "supportedFeatures" );
+ if ( sfAttribute != null )
+ {
+ for ( int sfi = 0; sfi < sfAttribute.getStringValues().length; sfi++ )
+ {
+ if ( "1.3.6.1.4.1.4203.1.5.4".equals( sfAttribute.getStringValues()[sfi] ) )
+ {
+ result = "OpenLDAP 2.0";
+ typeDetected = true;
+ }
+ }
+ }
+ }
+ if ( !typeDetected )
+ {
+ result = "OpenLDAP";
+ typeDetected = true;
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+
+ /**
+ * Add descriptions to OIDs, if known. uses the form "OID (description)". The array content is modified by this method.
+ *
+ * @param oids
+ */
+ private void addDescritionsToOIDs( String[] oids )
+ {
+ if ( oidDescriptions != null )
+ {
+ for ( int i = 0; i < oids.length; ++i )
+ {
+ try
+ {
+ String description = oidDescriptions.getString( oids[i] );
+ oids[i] = oids[i] + " (" + description + ")";
+ }
+ catch ( MissingResourceException ignored )
+ {
+ }
+ }
+ }
+ }
+
+
+ private void addInfo( final IBrowserConnection connection, Composite composite, String attributeName, String labelName )
+ {
+ Label label = new Label( composite, SWT.NONE );
+ label.setText( labelName );
+ Text text = new Text( composite, SWT.NONE );
+ text.setEditable( false );
+ text.setBackground( composite.getBackground() );
+ try
+ {
+ String[] versions = connection.getRootDSE().getAttribute( attributeName ).getStringValues();
+ String version = Arrays.asList( versions ).toString();
+ text.setText( version.substring( 1, version.length() - 1 ) );
+ }
+ catch ( Exception e )
+ {
+ text.setText( "-" );
+ }
+ }
+
+ class InnerContentProvider implements IStructuredContentProvider
+ {
+ public Object[] getElements( Object inputElement )
+ {
+ if ( inputElement instanceof IEntry )
+ {
+ IEntry entry = ( IEntry ) inputElement;
+ if ( !entry.isAttributesInitialized() && entry.isDirectoryEntry() )
+ {
+ return new Object[]
+ {};
+ }
+ else
+ {
+ IAttribute[] attributes = entry.getAttributes();
+ List valueList = new ArrayList();
+ for ( int i = 0; attributes != null && i < attributes.length; i++ )
+ {
+ IValue[] values = attributes[i].getValues();
+ for ( int j = 0; j < values.length; j++ )
+ {
+ valueList.add( values[j] );
+ }
+ }
+ return valueList.toArray();
+ }
+ }
+ return new Object[0];
+ }
+
+
+ public void dispose()
+ {
+ }
+
+
+ public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+ {
+ }
+ }
+
+ class InnerLabelProvider extends LabelProvider implements ITableLabelProvider
+ {
+ public String getColumnText( Object obj, int index )
+ {
+ if ( obj != null && obj instanceof IValue )
+ {
+ IValue attributeValue = ( IValue ) obj;
+ switch ( index )
+ {
+ case EntryEditorWidgetTableMetadata.KEY_COLUMN_INDEX:
+ return attributeValue.getAttribute().getDescription();
+ case EntryEditorWidgetTableMetadata.VALUE_COLUMN_INDEX:
+ return attributeValue.getStringValue();
+ default:
+ return "";
+ }
+ }
+ return "";
+ }
+
+
+ public Image getColumnImage( Object obj, int index )
+ {
+ return super.getImage( obj );
+ }
+ }
+
+ class InnerViewerSorter extends ViewerSorter
+ {
+
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/RootDSEPropertyPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SchemaAttributesPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SchemaAttributesPropertyPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SchemaAttributesPropertyPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SchemaAttributesPropertyPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,99 @@
+/*
+ * 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.studio.ldapbrowser.ui.dialogs.properties;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+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.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+
+public class SchemaAttributesPropertyPage extends PropertyPage implements IWorkbenchPropertyPage
+{
+
+ public SchemaAttributesPropertyPage()
+ {
+ super();
+ super.noDefaultAndApplyButton();
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ Table table = new Table( parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION
+ | SWT.HIDE_SELECTION );
+ GridData gridData = new GridData( GridData.FILL_BOTH );
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalSpan = 3;
+ table.setLayoutData( gridData );
+ table.setHeaderVisible( true );
+ table.setLinesVisible( true );
+ TableViewer viewer = new TableViewer( table );
+ TableColumn column = new TableColumn( table, SWT.LEFT, 0 );
+ column.setText( "Attribute Type Definition" );
+ column.setWidth( 200 );
+ column.setResizable( true );
+ viewer.setColumnProperties( new String[]
+ { "Attribute Type Definition" } );
+
+ viewer.setSorter( new ViewerSorter() );
+ viewer.setContentProvider( new ArrayContentProvider() );
+ viewer.setLabelProvider( new LabelProvider() );
+
+ if ( getElement() instanceof IBrowserConnection )
+ {
+ IBrowserConnection connection = ( IBrowserConnection ) getElement();
+ if ( connection != null )
+ {
+ Object[] atds = connection.getSchema().getAttributeTypeDescriptions();
+ viewer.setInput( atds );
+ column.pack();
+ }
+ }
+ else if ( getElement() instanceof IEntry )
+ {
+ IEntry entry = ( IEntry ) getElement();
+ if ( entry != null )
+ {
+ Object[] atds = entry.getSubschema().getAllAttributeNames();
+ viewer.setInput( atds );
+ column.pack();
+ }
+ }
+
+ // setControl(composite);
+ return parent;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SchemaAttributesPropertyPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SchemaObjectClassesPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SchemaObjectClassesPropertyPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SchemaObjectClassesPropertyPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SchemaObjectClassesPropertyPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,98 @@
+/*
+ * 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.studio.ldapbrowser.ui.dialogs.properties;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+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.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+
+public class SchemaObjectClassesPropertyPage extends PropertyPage implements IWorkbenchPropertyPage
+{
+
+ public SchemaObjectClassesPropertyPage()
+ {
+ super();
+ super.noDefaultAndApplyButton();
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ Table table = new Table( parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION
+ | SWT.HIDE_SELECTION );
+ GridData gridData = new GridData( GridData.FILL_BOTH );
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalSpan = 3;
+ table.setLayoutData( gridData );
+ table.setHeaderVisible( true );
+ table.setLinesVisible( true );
+ TableViewer viewer = new TableViewer( table );
+ TableColumn column = new TableColumn( table, SWT.LEFT, 0 );
+ column.setText( "Object Class Definition" );
+ column.setWidth( 200 );
+ column.setResizable( true );
+ viewer.setColumnProperties( new String[]
+ { "Object Class Definition" } );
+
+ viewer.setSorter( new ViewerSorter() );
+ viewer.setContentProvider( new ArrayContentProvider() );
+ viewer.setLabelProvider( new LabelProvider() );
+
+ if ( getElement() instanceof IBrowserConnection )
+ {
+ IBrowserConnection connection = ( IBrowserConnection ) getElement();
+ if ( connection != null )
+ {
+ Object[] ocds = connection.getSchema().getObjectClassDescriptions();
+ viewer.setInput( ocds );
+ column.pack();
+ }
+ }
+ else if ( getElement() instanceof IEntry )
+ {
+ IEntry entry = ( IEntry ) getElement();
+ if ( entry != null )
+ {
+ Object[] ocds = entry.getSubschema().getObjectClassNames();
+ viewer.setInput( ocds );
+ column.pack();
+ }
+ }
+
+ return parent;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SchemaObjectClassesPropertyPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SchemaPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SchemaPropertyPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SchemaPropertyPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SchemaPropertyPage.java Mon Nov 5 09:01:21 2007
@@ -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.studio.ldapbrowser.ui.dialogs.properties;
+
+
+import java.io.File;
+import java.text.DateFormat;
+import java.util.Date;
+
+import org.apache.directory.studio.ldapbrowser.common.jobs.RunnableContextJobAdapter;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.core.BrowserConnectionManager;
+import org.apache.directory.studio.ldapbrowser.core.jobs.ReloadSchemasJob;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
+import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+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.Group;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+
+public class SchemaPropertyPage extends PropertyPage implements IWorkbenchPropertyPage
+{
+
+ private Text dnText;
+
+ private Text ctText;
+
+ private Text mtText;
+
+ private Button reloadSchemaButton;
+
+ private Text cachePathText;
+
+ private Text cacheDateText;
+
+ private Text cacheSizeText;
+
+
+ public SchemaPropertyPage()
+ {
+ super();
+ super.noDefaultAndApplyButton();
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
+
+ Group infoGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ),
+ "Schema Information", 1 );
+ Composite infoComposite = BaseWidgetUtils.createColumnContainer( infoGroup, 2, 1 );
+ Composite infoGroupLeft = BaseWidgetUtils.createColumnContainer( infoComposite, 2, 1 );
+
+ BaseWidgetUtils.createLabel( infoGroupLeft, "Schema DN:", 1 );
+ dnText = BaseWidgetUtils.createWrappedLabeledText( infoGroupLeft, "", 1 );
+
+ BaseWidgetUtils.createLabel( infoGroupLeft, "Create Timestamp:", 1 );
+ ctText = BaseWidgetUtils.createWrappedLabeledText( infoGroupLeft, "", 1 );
+
+ BaseWidgetUtils.createLabel( infoGroupLeft, "Modify Timestamp:", 1 );
+ mtText = BaseWidgetUtils.createWrappedLabeledText( infoGroupLeft, "", 1 );
+
+ reloadSchemaButton = BaseWidgetUtils.createButton( infoComposite, "", 1 );
+ GridData gd = new GridData();
+ gd.verticalAlignment = SWT.BOTTOM;
+ reloadSchemaButton.setLayoutData( gd );
+ reloadSchemaButton.addSelectionListener( new SelectionListener()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ reloadSchema();
+ }
+
+
+ public void widgetDefaultSelected( SelectionEvent e )
+ {
+ }
+ } );
+
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+
+ Group cacheGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ),
+ "Schema Cache", 1 );
+ Composite cacheComposite = BaseWidgetUtils.createColumnContainer( cacheGroup, 2, 1 );
+
+ BaseWidgetUtils.createLabel( cacheComposite, "Cache Location:", 1 );
+ cachePathText = BaseWidgetUtils.createWrappedLabeledText( cacheComposite, "", 1 );
+
+ BaseWidgetUtils.createLabel( cacheComposite, "Cache Date:", 1 );
+ cacheDateText = BaseWidgetUtils.createWrappedLabeledText( cacheComposite, "", 1 );
+
+ BaseWidgetUtils.createLabel( cacheComposite, "Cache Size:", 1 );
+ cacheSizeText = BaseWidgetUtils.createWrappedLabeledText( cacheComposite, "", 1 );
+
+ IBrowserConnection connection = RootDSEPropertyPage.getConnection( getElement() );
+ this.connectionUpdated( connection );
+
+ return composite;
+ }
+
+
+ private void reloadSchema()
+ {
+ final IBrowserConnection browserConnection = RootDSEPropertyPage.getConnection( getElement() );
+ ReloadSchemasJob job = new ReloadSchemasJob( browserConnection );
+ RunnableContextJobAdapter.execute( job );
+ this.connectionUpdated( browserConnection );
+ }
+
+
+ private void connectionUpdated( IBrowserConnection connection )
+ {
+
+ if ( !this.dnText.isDisposed() )
+ {
+ Schema schema = null;
+ if ( connection != null )
+ {
+ schema = connection.getSchema();
+ }
+
+ if ( schema != null && schema.getDn() != null )
+ {
+ dnText.setText( schema.getDn().toString() );
+ }
+ else
+ {
+ dnText.setText( "-" );
+ }
+
+ if ( schema != null && schema.getCreateTimestamp() != null )
+ {
+ ctText.setText( schema.getCreateTimestamp() );
+ }
+ else
+ {
+ ctText.setText( "-" );
+ }
+
+ if ( schema != null && schema.getModifyTimestamp() != null )
+ {
+ mtText.setText( schema.getModifyTimestamp() );
+ }
+ else
+ {
+ mtText.setText( "-" );
+ }
+
+ if ( schema != null )
+ {
+ reloadSchemaButton.setText( "Reload Schema" );
+ }
+ else
+ {
+ reloadSchemaButton.setText( "Load Schema" );
+ }
+
+ if ( connection != null )
+ {
+ String cacheFileName = BrowserConnectionManager.getSchemaCacheFileName( connection );
+ File cacheFile = new File( cacheFileName );
+ if ( cacheFile.exists() )
+ {
+ cachePathText.setText( cacheFile.getPath() );
+ DateFormat format = DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.MEDIUM );
+ cacheDateText.setText( format.format( new Date( cacheFile.lastModified() ) ) );
+ cacheSizeText.setText( Utils.formatBytes( cacheFile.length() ) );
+ }
+ else
+ {
+ cachePathText.setText( "-" );
+ cacheDateText.setText( "-" );
+ cacheSizeText.setText( "-" );
+ }
+ }
+
+ reloadSchemaButton.setEnabled( true );
+ }
+ }
+
+
+ public boolean isDisposed()
+ {
+ return this.dnText.isDisposed();
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SchemaPropertyPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SearchPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SearchPropertyPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SearchPropertyPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SearchPropertyPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,135 @@
+/*
+ * 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.studio.ldapbrowser.ui.dialogs.properties;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.apache.directory.studio.ldapbrowser.common.widgets.search.SearchPageWrapper;
+import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
+import org.apache.directory.studio.ldapbrowser.core.events.SearchUpdateEvent;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.Search;
+import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+
+/**
+ * The SearchPropertyPage implements the property page for an {@link ISearch}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchPropertyPage extends PropertyPage implements IWorkbenchPropertyPage, WidgetModifyListener
+{
+
+ /** The search. */
+ private ISearch search;
+
+ /** The search page wrapper. */
+ private SearchPageWrapper spw;
+
+
+ /**
+ * Creates a new instance of SearchPropertyPage.
+ */
+ public SearchPropertyPage()
+ {
+ super();
+ super.noDefaultAndApplyButton();
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+ */
+ public void dispose()
+ {
+ spw.removeWidgetModifyListener( this );
+ super.dispose();
+ }
+
+
+ /**
+ * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createContents( Composite parent )
+ {
+
+ // declare search
+ ISearch search = ( ISearch ) getElement();
+ if ( search != null )
+ {
+ this.search = search;
+ }
+ else
+ {
+ this.search = new Search();
+ }
+
+ super.setMessage( "Search " + Utils.shorten( search.getName(), 30 ) );
+
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
+
+ spw = new SearchPageWrapper( SearchPageWrapper.CONNECTION_READONLY );
+ spw.createContents( composite );
+ spw.loadFromSearch( search );
+ spw.addWidgetModifyListener( this );
+
+ widgetModified( new WidgetModifyEvent( this ) );
+
+ return composite;
+ }
+
+
+ /**
+ * @see org.eclipse.jface.preference.PreferencePage#performOk()
+ */
+ public boolean performOk()
+ {
+ boolean modified = spw.saveToSearch( search );
+ if ( modified && search.getBrowserConnection() != null )
+ {
+ // send update event to force saving of new search parameters.
+ EventRegistry.fireSearchUpdated( new SearchUpdateEvent( search,
+ SearchUpdateEvent.EventDetail.SEARCH_PARAMETER_UPDATED ), this );
+
+ return spw.performSearch( search );
+ }
+
+ return true;
+ }
+
+
+ /**
+ * @see org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener#widgetModified(org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent)
+ */
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ setValid( spw.isValid() );
+ setErrorMessage( spw.getErrorMessage() );
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SearchPropertyPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SubSchemaPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SubSchemaPropertyPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SubSchemaPropertyPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SubSchemaPropertyPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,114 @@
+/*
+ * 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.studio.ldapbrowser.ui.dialogs.properties;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowData;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+
+public class SubSchemaPropertyPage extends PropertyPage implements IWorkbenchPropertyPage
+{
+
+ private TabFolder tabFolder;
+
+ private TabItem ocTab;
+
+ private TabItem atTab;
+
+
+ public SubSchemaPropertyPage()
+ {
+ super();
+ super.noDefaultAndApplyButton();
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ this.tabFolder = new TabFolder( parent, SWT.TOP );
+ RowLayout mainLayout = new RowLayout();
+ mainLayout.fill = true;
+ mainLayout.marginWidth = 0;
+ mainLayout.marginHeight = 0;
+ this.tabFolder.setLayout( mainLayout );
+
+ Composite ocComposite = new Composite( this.tabFolder, SWT.NONE );
+ ocComposite.setLayoutData( new RowData( 10, 10 ) );
+ GridLayout ocLayout = new GridLayout();
+ ocComposite.setLayout( ocLayout );
+ ListViewer ocViewer = new ListViewer( ocComposite );
+ ocViewer.getList().setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ ocViewer.setContentProvider( new ArrayContentProvider() );
+ ocViewer.setLabelProvider( new LabelProvider() );
+ if ( EntryPropertyPage.getEntry( getElement() ) != null )
+ {
+ IEntry entry = EntryPropertyPage.getEntry( getElement() );
+ if ( entry != null )
+ {
+ Object[] ocds = entry.getSubschema().getObjectClassNames();
+ ocViewer.setInput( ocds );
+ }
+ }
+ this.ocTab = new TabItem( this.tabFolder, SWT.NONE );
+ this.ocTab.setText( "Object Classes" );
+ this.ocTab.setControl( ocComposite );
+
+ Composite atComposite = new Composite( this.tabFolder, SWT.NONE );
+ atComposite.setLayoutData( new RowData( 10, 10 ) );
+ GridLayout atLayout = new GridLayout();
+ atComposite.setLayout( atLayout );
+ ListViewer atViewer = new ListViewer( atComposite );
+ atViewer.getList().setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ atViewer.setContentProvider( new ArrayContentProvider() );
+ atViewer.setLabelProvider( new LabelProvider() );
+ if ( EntryPropertyPage.getEntry( getElement() ) != null )
+ {
+ IEntry entry = EntryPropertyPage.getEntry( getElement() );
+ if ( entry != null )
+ {
+ Object[] atds = entry.getSubschema().getAllAttributeNames();
+ atViewer.setInput( atds );
+ }
+ }
+ this.atTab = new TabItem( this.tabFolder, SWT.NONE );
+ this.atTab.setText( "Attribute Types" );
+ this.atTab.setControl( atComposite );
+
+ return this.tabFolder;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SubSchemaPropertyPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/ValuePropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/ValuePropertyPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/ValuePropertyPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/ValuePropertyPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,123 @@
+/*
+ * 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.studio.ldapbrowser.ui.dialogs.properties;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+
+public class ValuePropertyPage extends PropertyPage implements IWorkbenchPropertyPage
+{
+
+ private Text descriptionText;
+
+ private Text valueText;
+
+ private Text typeText;
+
+ private Text sizeText;
+
+
+ public ValuePropertyPage()
+ {
+ super();
+ super.noDefaultAndApplyButton();
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ IValue value = getValue( getElement() );
+
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
+ Composite mainGroup = BaseWidgetUtils.createColumnContainer( composite, 2, 1 );
+
+ BaseWidgetUtils.createLabel( mainGroup, "Attribute Description:", 1 );
+ descriptionText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 );
+
+ BaseWidgetUtils.createLabel( mainGroup, "Value Type:", 1 );
+ typeText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 );
+
+ BaseWidgetUtils.createLabel( mainGroup, "Value Size:", 1 );
+ sizeText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 );
+
+ BaseWidgetUtils.createLabel( mainGroup, "Data:", 1 );
+ if ( value != null && value.isString() )
+ {
+ valueText = new Text( mainGroup, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY );
+ valueText.setFont( JFaceResources.getFont( JFaceResources.TEXT_FONT ) );
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ gd.widthHint = convertHorizontalDLUsToPixels( ( int ) ( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2 ) );
+ gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 4 );
+ valueText.setLayoutData( gd );
+ valueText.setBackground( parent.getBackground() );
+ }
+ else
+ {
+ valueText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 );
+ }
+
+ if ( value != null )
+ {
+
+ super.setMessage( "Value " + Utils.shorten( value.toString(), 30 ) );
+
+ descriptionText.setText( value.getAttribute().getDescription() );
+ // valueText.setText(LdifUtils.mustEncode(value.getBinaryValue())?"Binary":value.getStringValue());
+ valueText.setText( value.isString() ? value.getStringValue() : "Binary" );
+ typeText.setText( value.isString() ? "String" : "Binary" );
+
+ int bytes = value.getBinaryValue().length;
+ int chars = value.isString() ? value.getStringValue().length() : 0;
+ String size = value.isString() ? chars + ( chars > 1 ? " Characters, " : " Character, " ) : "";
+ size += Utils.formatBytes( bytes );
+ sizeText.setText( size );
+ }
+
+ return parent;
+ }
+
+
+ private static IValue getValue( Object element )
+ {
+ IValue value = null;
+ if ( element instanceof IAdaptable )
+ {
+ value = ( IValue ) ( ( IAdaptable ) element ).getAdapter( IValue.class );
+ }
+ return value;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/ValuePropertyPage.java
------------------------------------------------------------------------------
svn:eol-style = native