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 2007/10/29 13:49:22 UTC
svn commit: r589607 - in
/directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser:
BrowserConnectionWidgetContributionItem.java
ConnectionComboContributionItem.java SchemaPage.java
Author: pamarcelot
Date: Mon Oct 29 05:49:22 2007
New Revision: 589607
URL: http://svn.apache.org/viewvc?rev=589607&view=rev
Log:
Modified the Schema Editor to use the Connection Widget for selecting a connection instead of a Connection Combo (that was not suitable anymore because of the addition of the connection folders).
Added:
directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/BrowserConnectionWidgetContributionItem.java
Removed:
directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/ConnectionComboContributionItem.java
Modified:
directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaPage.java
Added: directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/BrowserConnectionWidgetContributionItem.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/BrowserConnectionWidgetContributionItem.java?rev=589607&view=auto
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/BrowserConnectionWidgetContributionItem.java (added)
+++ directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/BrowserConnectionWidgetContributionItem.java Mon Oct 29 05:49:22 2007
@@ -0,0 +1,188 @@
+/*
+ * 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.editors.schemabrowser;
+
+
+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.BrowserConnectionWidget;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.eclipse.jface.action.ContributionItem;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+
+/**
+ * A contribution item that adds a BrowserConnectionWidget with connections to the toolbar.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BrowserConnectionWidgetContributionItem extends ContributionItem
+{
+ /** The schema page */
+ private SchemaPage schemaPage;
+
+ /** The tool item */
+ private ToolItem toolitem;
+
+ /** The tool item composite */
+ private Composite toolItemComposite;
+ private BrowserConnectionWidget browserConnectionWidget;
+
+
+ /**
+ * Creates a new instance of ConnectionContributionItem.
+ *
+ * @param schemaPage the schema page
+ */
+ public BrowserConnectionWidgetContributionItem( SchemaPage schemaPage )
+ {
+ this.schemaPage = schemaPage;
+ }
+
+
+ /**
+ * Creates and returns the control for this contribution item
+ * under the given parent composite.
+ *
+ * @param parent the parent composite
+ * @return the new control
+ */
+ private Control createControl( Composite parent )
+ {
+ // Creating the ToolItem Composite
+ toolItemComposite = new Composite( parent, SWT.NONE );
+ GridLayout gridLayout = new GridLayout( 2, false );
+ gridLayout.marginWidth = 0;
+ gridLayout.marginHeight = 0;
+ toolItemComposite.setLayout( gridLayout );
+ toolItemComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Creating the Browser Connection Widget
+ browserConnectionWidget = new BrowserConnectionWidget();
+ browserConnectionWidget.createWidget( toolItemComposite );
+ browserConnectionWidget.addWidgetModifyListener( new WidgetModifyListener()
+ {
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ schemaPage.getSchemaBrowser().setInput( new SchemaBrowserInput( getConnection(), null ) );
+ }
+ } );
+
+ // Initializing the width for the toolbar item
+ toolitem.setWidth( 250 );
+
+ return toolItemComposite;
+ }
+
+
+ /**
+ * @see org.eclipse.jface.action.ContributionItem#dispose()
+ */
+ public void dispose()
+ {
+ toolItemComposite.dispose();
+ toolItemComposite = null;
+ browserConnectionWidget = null;
+ }
+
+
+ /**
+ * The control item implementation of this <code>IContributionItem</code>
+ * method calls the <code>createControl</code> method.
+ *
+ * @param parent the parent of the control to fill
+ */
+ public final void fill( Composite parent )
+ {
+ createControl( parent );
+ }
+
+
+ /**
+ * The control item implementation of this <code>IContributionItem</code>
+ * method throws an exception since controls cannot be added to menus.
+ *
+ * @param parent the menu
+ * @param index menu index
+ */
+ public final void fill( Menu parent, int index )
+ {
+ Assert.isTrue( false, "Can't add a control to a menu" );//$NON-NLS-1$
+ }
+
+
+ /**
+ * The control item implementation of this <code>IContributionItem</code>
+ * method calls the <code>createControl</code> method to
+ * create a control under the given parent, and then creates
+ * a new tool item to hold it.
+ *
+ * @param parent the ToolBar to add the new control to
+ * @param index the index
+ */
+ public void fill( ToolBar parent, int index )
+ {
+ toolitem = new ToolItem( parent, SWT.SEPARATOR, index );
+ Control control = createControl( parent );
+ toolitem.setControl( control );
+ }
+
+
+ /**
+ * Gets the connection.
+ *
+ * @return the connection
+ */
+ public IBrowserConnection getConnection()
+ {
+ return browserConnectionWidget.getBrowserConnection();
+ }
+
+
+ /**
+ * Sets the connection.
+ *
+ * @param connection the connection
+ */
+ public void setConnection( IBrowserConnection connection )
+ {
+ browserConnectionWidget.setBrowserConnection( connection );
+ }
+
+
+ /**
+ * Updates the enabled state.
+ */
+ public void updateEnabledState()
+ {
+ browserConnectionWidget.setEnabled( !schemaPage.isShowDefaultSchema() );
+ }
+
+}
\ No newline at end of file
Modified: directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaPage.java?rev=589607&r1=589606&r2=589607&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaPage.java (original)
+++ directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaPage.java Mon Oct 29 05:49:22 2007
@@ -21,7 +21,6 @@
package org.apache.directory.studio.ldapbrowser.ui.editors.schemabrowser;
-import org.apache.directory.studio.connection.core.Connection;
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.model.schema.SchemaPart;
@@ -63,8 +62,8 @@
public abstract class SchemaPage
{
- /** The connection combo */
- protected ConnectionComboContributionItem connectionCombo;
+ /** The connection widget */
+ protected BrowserConnectionWidgetContributionItem connectionCombo;
/** The show default schema action */
protected ShowDefaultSchemaAction showDefaultSchemaAction;
@@ -359,7 +358,7 @@
}
} );
- connectionCombo = new ConnectionComboContributionItem( this );
+ connectionCombo = new BrowserConnectionWidgetContributionItem( this );
this.form.getToolBarManager().add( connectionCombo );
this.form.getToolBarManager().add( new Separator() );
showDefaultSchemaAction = new ShowDefaultSchemaAction( schemaBrowser );