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 [12/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/properties/BookmarkPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/BookmarkPropertyPage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/BookmarkPropertyPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/BookmarkPropertyPage.java Mon Dec 18 09:52:58 2006
@@ -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.ldapstudio.browser.ui.dialogs.properties;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IBookmark;
+import org.apache.directory.ldapstudio.browser.core.utils.Utils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyEvent;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyListener;
+import org.apache.directory.ldapstudio.browser.ui.widgets.search.EntryWidget;
+
+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.getConnection(), 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.getConnection().getBookmarkManager().getBookmark( this.bookmarkNameText.getText() ) != null )
+ {
+ setValid( false );
+ setErrorMessage( "A bookmark with this name already exists." );
+ }
+ else
+ {
+ setValid( true );
+ setErrorMessage( null );
+ }
+ }
+ else
+ {
+ setValid( false );
+ }
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/ConnectionPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/ConnectionPropertyPage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/ConnectionPropertyPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/ConnectionPropertyPage.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,207 @@
+/*
+ * 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.properties;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.NameException;
+import org.apache.directory.ldapstudio.browser.core.utils.Utils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.connection.ConnectionPageModifyListener;
+import org.apache.directory.ldapstudio.browser.ui.widgets.connection.ConnectionPageWrapper;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+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.dialogs.PropertyPage;
+
+
+public class ConnectionPropertyPage extends PropertyPage implements ConnectionPageModifyListener
+{
+
+ private TabFolder tabFolder;
+
+ private TabItem networkTab;
+
+ private TabItem authTab;
+
+ private TabItem optionsTab;
+
+ private ConnectionPageWrapper cpw;
+
+
+ public ConnectionPropertyPage()
+ {
+ super();
+ super.noDefaultAndApplyButton();
+ }
+
+
+ public void connectionPageModified()
+ {
+ validate();
+ }
+
+
+ public void setMessage( String message )
+ {
+ super.setMessage( message, PropertyPage.WARNING );
+ getContainer().updateTitle();
+ getContainer().updateMessage();
+ validate();
+ }
+
+
+ public void setErrorMessage( String errorMessage )
+ {
+ super.setErrorMessage( errorMessage );
+ getContainer().updateTitle();
+ getContainer().updateMessage();
+ validate();
+ }
+
+
+ public IConnection getRealConnection()
+ {
+ return getConnection( getElement() );
+ }
+
+
+ private void validate()
+ {
+ setValid( getMessage() == null && getErrorMessage() == null );
+ }
+
+
+ static IConnection getConnection( Object element )
+ {
+ IConnection connection = null;
+ if ( element instanceof IAdaptable )
+ {
+ connection = ( IConnection ) ( ( IAdaptable ) element ).getAdapter( IConnection.class );
+ }
+ return connection;
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ IConnection connection = ( IConnection ) getConnection( getElement() );
+ if ( connection != null )
+ {
+ super.setMessage( "Connection " + Utils.shorten( connection.getName(), 30 ) );
+ }
+
+ this.tabFolder = new TabFolder( parent, SWT.TOP );
+
+ this.cpw = new ConnectionPageWrapper( this, null );
+
+ Composite networkComposite = new Composite( this.tabFolder, SWT.NONE );
+ GridLayout gl = new GridLayout( 1, false );
+ networkComposite.setLayout( gl );
+ cpw.addMainInput( connection.getName(), connection.getHost(), connection.getPort(), connection
+ .getEncryptionMethod(), networkComposite );
+ this.networkTab = new TabItem( this.tabFolder, SWT.NONE );
+ this.networkTab.setText( "Network Parameter" );
+ this.networkTab.setControl( networkComposite );
+
+ Composite authComposite = new Composite( this.tabFolder, SWT.NONE );
+ gl = new GridLayout( 1, false );
+ authComposite.setLayout( gl );
+ cpw.addAuthenticationMethodInput( connection.getAuthMethod(), authComposite );
+ cpw.addSimpleAuthInput( connection.getBindPassword() != null,
+ connection.getBindPrincipal() != null ? connection.getBindPrincipal().toString() : "", connection
+ .getBindPassword() != null ? connection.getBindPassword() : "", authComposite );
+ this.authTab = new TabItem( this.tabFolder, SWT.NONE );
+ this.authTab.setText( "Authentification" );
+ this.authTab.setControl( authComposite );
+
+ Composite optionsComposite = new Composite( this.tabFolder, SWT.NONE );
+ gl = new GridLayout( 1, false );
+ optionsComposite.setLayout( gl );
+ cpw.addBaseDNInput( connection.isFetchBaseDNs(), connection.getBaseDN().toString(), optionsComposite );
+ cpw.addLimitInput( connection.getCountLimit(), connection.getTimeLimit(), connection
+ .getAliasesDereferencingMethod(), connection.getReferralsHandlingMethod(), optionsComposite );
+
+ this.optionsTab = new TabItem( this.tabFolder, SWT.NONE );
+ this.optionsTab.setText( "Options" );
+ this.optionsTab.setControl( optionsComposite );
+
+ return tabFolder;
+ }
+
+
+ public boolean performOk()
+ {
+
+ IConnection connection = ( IConnection ) getConnection( getElement() );
+
+ if ( connection instanceof IConnection )
+ {
+ connection.setName( cpw.getName() );
+ connection.setHost( cpw.getHostName() );
+ connection.setPort( cpw.getPort() );
+ connection.setEncryptionMethod( cpw.getEncyrptionMethod() );
+
+ connection.setAuthMethod( cpw.getAuthenticationMethod() );
+
+ connection.setFetchBaseDNs( cpw.isAutoFetchBaseDns() );
+ try
+ {
+ connection.setBaseDN( new DN( cpw.getBaseDN() ) );
+ }
+ catch ( NameException e )
+ {
+ }
+ connection.setCountLimit( cpw.getCountLimit() );
+ connection.setTimeLimit( cpw.getTimeLimit() );
+ connection.setAliasesDereferencingMethod( cpw.getAliasesDereferencingMethod() );
+ connection.setReferralsHandlingMethod( cpw.getReferralsHandlingMethod() );
+ }
+
+ if ( connection.getAuthMethod() == IConnection.AUTH_ANONYMOUS )
+ {
+ connection.setBindPrincipal( null );
+ connection.setBindPassword( null );
+ }
+ if ( connection.getAuthMethod() == IConnection.AUTH_SIMPLE )
+ {
+ try
+ {
+ connection.setBindPrincipal( cpw.getSimpleAuthBindDN() );
+ connection
+ .setBindPassword( cpw.isSaveSimpleAuthBindPassword() ? cpw.getSimpleAuthBindPassword() : null );
+ }
+ catch ( Exception e )
+ {
+ }
+ }
+
+ cpw.saveDialogSettings();
+ return true;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/EntryPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/EntryPropertyPage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/EntryPropertyPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/EntryPropertyPage.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,306 @@
+/*
+ * 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.properties;
+
+
+import org.apache.directory.ldapstudio.browser.core.events.EntryModificationEvent;
+import org.apache.directory.ldapstudio.browser.core.jobs.InitializeAttributesJob;
+import org.apache.directory.ldapstudio.browser.core.jobs.InitializeChildrenJob;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.utils.Utils;
+import org.apache.directory.ldapstudio.browser.ui.jobs.RunnableContextJobAdapter;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+
+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() );
+
+ this.dnText.setText( entry.getDn().toString() );
+ 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 ) );
+ }
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/RootDSEPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/RootDSEPropertyPage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/RootDSEPropertyPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/RootDSEPropertyPage.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,419 @@
+/*
+ * 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.properties;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidgetTableMetadata;
+
+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 RootDSEPropertyPage()
+ {
+ super();
+ super.noDefaultAndApplyButton();
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ final IConnection connection = ConnectionPropertyPage.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 )
+ {
+
+ boolean typeDetected = false;
+
+ // check OpenLDAP
+ IAttribute ocAttribute = connection.getRootDSE().getAttribute( "objectClass" );
+ if ( ocAttribute != null )
+ {
+ for ( int i = 0; i < ocAttribute.getStringValues().length; i++ )
+ {
+ if ( "OpenLDAProotDSE".equals( ocAttribute.getStringValues()[i] ) )
+ {
+ IAttribute ccAttribute = connection.getRootDSE().getAttribute( "configContext" );
+ if ( ccAttribute != null )
+ {
+ typeText.setText( "OpenLDAP 2.3" );
+ typeDetected = true;
+ }
+ if ( !typeDetected )
+ {
+ IAttribute scAttribute = connection.getRootDSE().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] ) )
+ {
+ typeText.setText( "OpenLDAP 2.2" );
+ typeDetected = true;
+ }
+ }
+ }
+
+ }
+ if ( !typeDetected )
+ {
+ IAttribute seAttribute = connection.getRootDSE().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] ) )
+ {
+ typeText.setText( "OpenLDAP 2.1" );
+ typeDetected = true;
+ }
+ }
+ }
+ }
+ if ( !typeDetected )
+ {
+ IAttribute sfAttribute = connection.getRootDSE().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] ) )
+ {
+ typeText.setText( "OpenLDAP 2.0" );
+ typeDetected = true;
+ }
+ }
+ }
+ }
+ if ( !typeDetected )
+ {
+ typeText.setText( "OpenLDAP" );
+ typeDetected = true;
+ }
+ }
+ }
+ }
+
+ // check Siemens DirX
+ IAttribute ssseAttribute = connection.getRootDSE().getAttribute( "subSchemaSubentry" );
+ if ( ssseAttribute != null )
+ {
+ for ( int i = 0; i < ssseAttribute.getStringValues().length; i++ )
+ {
+ if ( "cn=LDAPGlobalSchemaSubentry".equals( ssseAttribute.getStringValues()[i] ) )
+ {
+ typeText.setText( "Siemens DirX" );
+ }
+ }
+ }
+
+ // check active directory
+ IAttribute rdncAttribute = connection.getRootDSE().getAttribute( "rootDomainNamingContext" );
+ if ( rdncAttribute != null )
+ {
+ IAttribute ffAttribute = connection.getRootDSE().getAttribute( "forestFunctionality" );
+ if ( ffAttribute != null )
+ {
+ typeText.setText( "Microsoft Active Directory 2003" );
+ }
+ else
+ {
+ typeText.setText( "Microsoft Active Directory 2000" );
+ }
+ }
+
+ // check Novell eDirectory / Sun Directory Server / Netscape
+ // Directory Server
+ IAttribute vnAttribute = connection.getRootDSE().getAttribute( "vendorName" );
+ IAttribute vvAttribute = connection.getRootDSE().getAttribute( "vendorVersion" );
+ if ( vnAttribute != null && vnAttribute.getStringValues().length > 0 && vvAttribute != null
+ && vvAttribute.getStringValues().length > 0 )
+ {
+ if ( vnAttribute.getStringValues()[0].indexOf( "Novell" ) > -1
+ || vvAttribute.getStringValues()[0].indexOf( "eDirectory" ) > -1 )
+ {
+ typeText.setText( "Novell eDirectory" );
+ }
+ if ( vnAttribute.getStringValues()[0].indexOf( "Sun" ) > -1
+ || vvAttribute.getStringValues()[0].indexOf( "Sun" ) > -1 )
+ {
+ typeText.setText( "Sun Directory Server" );
+ }
+ if ( vnAttribute.getStringValues()[0].indexOf( "Netscape" ) > -1
+ || vvAttribute.getStringValues()[0].indexOf( "Netscape" ) > -1 )
+ {
+ typeText.setText( "Netscape Directory Server" );
+ }
+ }
+ }
+ 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 )
+ {
+ controlsViewer.setInput( connection.getRootDSE().getSupportedControls() );
+ }
+ 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 )
+ {
+ extensionViewer.setInput( connection.getRootDSE().getSupportedExtensions() );
+ }
+ 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 )
+ {
+ featureViewer.setInput( connection.getRootDSE().getSupportedFeatures() );
+ }
+ 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;
+ }
+
+
+ private void addInfo( final IConnection 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
+ {
+
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SchemaAttributesPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SchemaAttributesPropertyPage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SchemaAttributesPropertyPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SchemaAttributesPropertyPage.java Mon Dec 18 09:52:58 2006
@@ -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.ldapstudio.browser.ui.dialogs.properties;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.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 IConnection )
+ {
+ IConnection connection = ( IConnection ) 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;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SchemaObjectClassesPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SchemaObjectClassesPropertyPage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SchemaObjectClassesPropertyPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SchemaObjectClassesPropertyPage.java Mon Dec 18 09:52:58 2006
@@ -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.ldapstudio.browser.ui.dialogs.properties;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.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 IConnection )
+ {
+ IConnection connection = ( IConnection ) 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;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SchemaPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SchemaPropertyPage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SchemaPropertyPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SchemaPropertyPage.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,226 @@
+/*
+ * 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.properties;
+
+
+import java.io.File;
+import java.text.DateFormat;
+import java.util.Date;
+
+import org.apache.directory.ldapstudio.browser.core.ConnectionManager;
+import org.apache.directory.ldapstudio.browser.core.jobs.ReloadSchemasJob;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+import org.apache.directory.ldapstudio.browser.core.utils.Utils;
+import org.apache.directory.ldapstudio.browser.ui.jobs.RunnableContextJobAdapter;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+
+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 );
+
+ IConnection connection = ConnectionPropertyPage.getConnection( getElement() );
+ this.connectionUpdated( connection );
+
+ return composite;
+ }
+
+
+ private void reloadSchema()
+ {
+ final IConnection connection = ConnectionPropertyPage.getConnection( getElement() );
+ ReloadSchemasJob job = new ReloadSchemasJob( new IConnection[]
+ { connection } );
+ RunnableContextJobAdapter.execute( job );
+ this.connectionUpdated( connection );
+ }
+
+
+ private void connectionUpdated( IConnection 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 = ConnectionManager.getSchemaCacheFileName( connection.getName() );
+ 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( "-" );
+ }
+ }
+
+ if ( connection != null && connection.isOpened() )
+ {
+ reloadSchemaButton.setEnabled( true );
+ }
+ else
+ {
+ reloadSchemaButton.setEnabled( true );
+ }
+ }
+ }
+
+
+ public boolean isDisposed()
+ {
+ return this.dnText.isDisposed();
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SearchPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SearchPropertyPage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SearchPropertyPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SearchPropertyPage.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,110 @@
+/*
+ * 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.properties;
+
+
+import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
+import org.apache.directory.ldapstudio.browser.core.events.SearchUpdateEvent;
+import org.apache.directory.ldapstudio.browser.core.internal.model.Search;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.core.utils.Utils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyEvent;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyListener;
+import org.apache.directory.ldapstudio.browser.ui.widgets.search.SearchPageWrapper;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+
+public class SearchPropertyPage extends PropertyPage implements IWorkbenchPropertyPage, WidgetModifyListener
+{
+
+ private ISearch search;
+
+ private SearchPageWrapper spw;
+
+
+ public SearchPropertyPage()
+ {
+ super();
+ super.noDefaultAndApplyButton();
+ }
+
+
+ public void dispose()
+ {
+ this.spw.removeWidgetModifyListener( this );
+ super.dispose();
+ }
+
+
+ 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 );
+
+ this.spw = new SearchPageWrapper( SearchPageWrapper.CONNECTION_READONLY );
+ this.spw.createContents( composite );
+ this.spw.loadFromSearch( this.search );
+ this.spw.addWidgetModifyListener( this );
+
+ return composite;
+ }
+
+
+ public boolean performOk()
+ {
+ boolean modified = this.spw.saveToSearch( this.search );
+ if ( modified && this.search.getConnection() != null && this.search.getConnection().isOpened() )
+ {
+ // send update event to force saving of new search parameters.
+ EventRegistry.fireSearchUpdated( new SearchUpdateEvent( this.search,
+ SearchUpdateEvent.SEARCH_PARAMETER_UPDATED ), this );
+
+ return this.spw.performSearch( this.search );
+ }
+
+ return true;
+ }
+
+
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ setValid( this.spw.isValid() );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SubSchemaPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SubSchemaPropertyPage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SubSchemaPropertyPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/SubSchemaPropertyPage.java Mon Dec 18 09:52:58 2006
@@ -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.ldapstudio.browser.ui.dialogs.properties;
+
+
+import org.apache.directory.ldapstudio.browser.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;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/ValuePropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/ValuePropertyPage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/ValuePropertyPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/properties/ValuePropertyPage.java Mon Dec 18 09:52:58 2006
@@ -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.ldapstudio.browser.ui.dialogs.properties;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.utils.Utils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+
+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;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/BrowserTransfer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/BrowserTransfer.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/BrowserTransfer.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/BrowserTransfer.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,182 @@
+/*
+ * 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.dnd;
+
+
+import org.eclipse.swt.dnd.ByteArrayTransfer;
+import org.eclipse.swt.dnd.TransferData;
+
+
+// TODO: Browser Drag 'n' Drop
+public class BrowserTransfer extends ByteArrayTransfer
+{
+
+ public static final String TYPENAME = "org.apache.directory.ldapstudio.browser.browser";
+
+ private static final int TYPEID = registerType( TYPENAME );
+
+ private static BrowserTransfer instance = new BrowserTransfer();
+
+
+ private BrowserTransfer()
+ {
+ }
+
+
+ public static BrowserTransfer getInstance()
+ {
+ return instance;
+ }
+
+
+ public void javaToNative( Object object, TransferData transferData )
+ {
+
+ if ( object == null || !( object instanceof String ) )
+ return;
+
+ if ( isSupportedType( transferData ) )
+ {
+ super.javaToNative( ( ( String ) object ).getBytes(), transferData );
+
+ /*
+ * BrowserTransferObject bto = (BrowserTransferObject) object;
+ * try { ByteArrayOutputStream out = new
+ * ByteArrayOutputStream(); DataOutputStream writeOut = new
+ * DataOutputStream(out);
+ *
+ * writeOut.writeInt(bto.getTransferType());
+ *
+ * IEntry[] entries = bto.getEntriesToTransfer();
+ * writeOut.writeInt(entries.length); for(int i=0; i<entries.length;
+ * i++) { byte[] connectionName =
+ * entries[i].getConnection().getName().getBytes();
+ * writeOut.writeInt(connectionName.length);
+ * writeOut.write(connectionName); byte[] dn =
+ * entries[i].getDn().getBytes(); writeOut.writeInt(dn.length);
+ * writeOut.write(dn); }
+ *
+ * ISearch[] searches = bto.getSearchesToTransfer();
+ * writeOut.writeInt(searches.length); for(int i=0; i<searches.length;
+ * i++) { byte[] connectionName =
+ * searches[i].getConnection().getName().getBytes();
+ * writeOut.writeInt(connectionName.length);
+ * writeOut.write(connectionName); byte[] searchName =
+ * searches[i].getName().getBytes();
+ * writeOut.writeInt(searchName.length);
+ * writeOut.write(searchName); }
+ *
+ * byte[] buffer = out.toByteArray(); writeOut.close();
+ *
+ * super.javaToNative(buffer, transferData);
+ * } catch (IOException e) { }
+ */
+ }
+ }
+
+
+ public Object nativeToJava( TransferData transferData )
+ {
+
+ try
+ {
+ if ( isSupportedType( transferData ) )
+ {
+
+ byte[] buffer = ( byte[] ) super.nativeToJava( transferData );
+ if ( buffer != null )
+ {
+ return new String( buffer );
+ }
+ else
+ {
+ return null;
+ }
+
+ /*
+ * byte[] buffer = (byte[]) super.nativeToJava(transferData); if
+ * (buffer == null) return null;
+ *
+ * try { IConnection connection = null; ByteArrayInputStream in =
+ * new ByteArrayInputStream(buffer); DataInputStream readIn =
+ * new DataInputStream(in);
+ *
+ * int transferType = readIn.readInt();
+ *
+ * int numberOfEntries = readIn.readInt(); IEntry[]
+ * entriesToTransfer = new IEntry[numberOfEntries]; for(int i=0;
+ * i<numberOfEntries; i++) { if(readIn.available() > 1) { int
+ * size = readIn.readInt(); byte[] connectionName = new
+ * byte[size]; readIn.read(connectionName); connection =
+ * BrowserPlugin.getDefault().getConnectionManager().getConnection(new
+ * String(connectionName)); } if(readIn.available() > 1 &&
+ * connection != null) { int size = readIn.readInt(); byte[] dn =
+ * new byte[size]; readIn.read(dn); InitializerProgressMonitor
+ * ipm = new InitializerProgressMonitor(){ public void
+ * reportProgress(String message) { } public void
+ * reportError(String message, Throwable exception) { } public
+ * boolean isCanceled() { return false; } public Throwable
+ * getReportedErrorThrowable() { return null; } public String
+ * getReportedErrorMessage() { return null; } };
+ * entriesToTransfer[i] = connection.getEntry(new String(dn),
+ * ipm); } }
+ *
+ * int numberOfSearches = readIn.readInt(); ISearch[]
+ * searchesToTransfer = new ISearch[numberOfSearches]; for(int
+ * i=0; i<numberOfSearches; i++) { if(readIn.available() > 1) {
+ * int size = readIn.readInt(); byte[] connectionName = new
+ * byte[size]; readIn.read(connectionName); connection =
+ * BrowserPlugin.getDefault().getConnectionManager().getConnection(new
+ * String(connectionName)); } if(readIn.available() > 1 &&
+ * connection != null) { int size = readIn.readInt(); byte[]
+ * searchName = new byte[size]; readIn.read(searchName);
+ * searchesToTransfer[i] =
+ * connection.getSearchManager().getSearch(new
+ * String(searchName)); } }
+ *
+ * readIn.close();
+ *
+ * return new BrowserTransferObject(entriesToTransfer,
+ * searchesToTransfer); } catch (IOException ex) { return null; }
+ */
+ }
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+
+ protected String[] getTypeNames()
+ {
+ return new String[]
+ { TYPENAME };
+ }
+
+
+ protected int[] getTypeIds()
+ {
+ return new int[]
+ { TYPEID };
+ }
+}
\ No newline at end of file
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/BrowserTransferObject.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/BrowserTransferObject.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/BrowserTransferObject.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/BrowserTransferObject.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,112 @@
+/*
+ * 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.dnd;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+
+
+// TODO: Browser Drag 'n' Drop
+public class BrowserTransferObject
+{
+
+ public static final int TYPE_UNKNOWN = 0;
+
+ public static final int TYPE_ENTRY_TRANSFER = 1;
+
+ public static final int TYPE_SEARCH_TRANSFER = 2;
+
+ private int transferType;
+
+ private IEntry[] entriesToTransfer;
+
+ private ISearch[] searchesToTransfer;
+
+
+ public BrowserTransferObject()
+ {
+ this.transferType = TYPE_UNKNOWN;
+ this.entriesToTransfer = new IEntry[0];
+ this.searchesToTransfer = new ISearch[0];
+ }
+
+
+ public BrowserTransferObject( IEntry[] entriesToTransfer )
+ {
+ this();
+ this.initEntriesToTransfer( entriesToTransfer );
+ }
+
+
+ public BrowserTransferObject( ISearch[] searchesToTransfer )
+ {
+ this();
+ this.initSearchesToTransfer( searchesToTransfer );
+ }
+
+
+ public BrowserTransferObject( IEntry[] entriesToTransfer, ISearch[] searchesToTransfer )
+ {
+ this();
+ this.initEntriesToTransfer( entriesToTransfer );
+ this.initSearchesToTransfer( searchesToTransfer );
+ }
+
+
+ private void initEntriesToTransfer( IEntry[] entriesToTransfer )
+ {
+ if ( entriesToTransfer != null || entriesToTransfer.length > 0 )
+ {
+ this.transferType |= TYPE_ENTRY_TRANSFER;
+ this.entriesToTransfer = entriesToTransfer;
+ }
+ }
+
+
+ private void initSearchesToTransfer( ISearch[] searchesToTransfer )
+ {
+ if ( searchesToTransfer != null || searchesToTransfer.length > 0 )
+ {
+ this.transferType |= TYPE_SEARCH_TRANSFER;
+ this.searchesToTransfer = searchesToTransfer;
+ }
+ }
+
+
+ public IEntry[] getEntriesToTransfer()
+ {
+ return entriesToTransfer;
+ }
+
+
+ public ISearch[] getSearchesToTransfer()
+ {
+ return searchesToTransfer;
+ }
+
+
+ public int getTransferType()
+ {
+ return transferType;
+ }
+
+}