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 17:48:54 UTC
svn commit: r592079 [5/17] - in
/directory/sandbox/felixk/studio-ldapbrowser-common: ./ 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/ ...
Propchange: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/RenameEntryDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/ScopeDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/ScopeDialog.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/ScopeDialog.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/ScopeDialog.java Mon Nov 5 08:48:35 2007
@@ -0,0 +1,149 @@
+/*
+ * 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.common.dialogs;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch.SearchScope;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+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.Shell;
+
+
+/**
+ * A dialog to select the scope of a copy operation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ScopeDialog extends Dialog
+{
+
+ /** The dialog title. */
+ private String dialogTitle;
+
+ /** The multiple entries selected flag. */
+ private boolean multipleEntriesSelected;
+
+ /** The scope. */
+ private SearchScope scope;
+
+ /** The object scope button. */
+ private Button objectScopeButton;
+
+ /** The onelevel scope button. */
+ private Button onelevelScopeButton;
+
+ /** The subtree scope button. */
+ private Button subtreeScopeButton;
+
+
+ /**
+ * Creates a new instance of ScopeDialog.
+ *
+ * @param parentShell the parent shell
+ * @param dialogTitle the dialog title
+ * @param multipleEntriesSelected the multiple entries selected
+ */
+ public ScopeDialog( Shell parentShell, String dialogTitle, boolean multipleEntriesSelected )
+ {
+ super( parentShell );
+ super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+ this.dialogTitle = dialogTitle;
+ this.multipleEntriesSelected = multipleEntriesSelected;
+ }
+
+
+ /**
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell( Shell shell )
+ {
+ super.configureShell( shell );
+ shell.setText( dialogTitle );
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed()
+ {
+ scope = objectScopeButton.getSelection() ? SearchScope.OBJECT
+ : onelevelScopeButton.getSelection() ? SearchScope.ONELEVEL : SearchScope.SUBTREE;
+ super.okPressed();
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ protected void createButtonsForButtonBar( Composite parent )
+ {
+ createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+ createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea( Composite parent )
+ {
+ Composite composite = ( Composite ) super.createDialogArea( parent );
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ composite.setLayoutData( gd );
+
+ Group group = BaseWidgetUtils.createGroup( composite, "Please select the copy depth", 1 );
+ objectScopeButton = new Button( group, SWT.RADIO );
+ objectScopeButton.setSelection( true );
+ objectScopeButton.setText( multipleEntriesSelected ? "&Object (Only the copied entries)"
+ : "&Object (Only the copied entry)" );
+ onelevelScopeButton = new Button( group, SWT.RADIO );
+ onelevelScopeButton
+ .setText( multipleEntriesSelected ? "O&ne Level (The copied entries and their direct children)"
+ : "O&ne Level (The copied entry and its direct children)" );
+ subtreeScopeButton = new Button( group, SWT.RADIO );
+ subtreeScopeButton.setText( multipleEntriesSelected ? "&Subtree (The whole subtrees)"
+ : "&Subtree (The whole subtree)" );
+
+ applyDialogFont( composite );
+ return composite;
+ }
+
+
+ /**
+ * Gets the scope.
+ *
+ * @return the scope
+ */
+ public SearchScope getScope()
+ {
+ return scope;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/ScopeDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/SelectBrowserConnectionDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/SelectBrowserConnectionDialog.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/SelectBrowserConnectionDialog.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/SelectBrowserConnectionDialog.java Mon Nov 5 08:48:35 2007
@@ -0,0 +1,252 @@
+/*
+ * 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.common.dialogs;
+
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionActionGroup;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionConfiguration;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionUniversalListener;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionWidget;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+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.Shell;
+
+
+/**
+ * Dialog to select an {@link IBrowserConnection}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SelectBrowserConnectionDialog extends Dialog
+{
+
+ /** The title. */
+ private String title;
+
+ /** The initial browser connection. */
+ private IBrowserConnection initialBrowserConnection;
+
+ /** The selected browser connection. */
+ private IBrowserConnection selectedBrowserConnection;
+
+ /** The connection configuration. */
+ private ConnectionConfiguration connectionConfiguration;
+
+ /** The connection universal listener. */
+ private ConnectionUniversalListener connectionUniversalListener;
+
+ /** The connection action group. */
+ private ConnectionActionGroup connectionActionGroup;
+
+ /** The connection main widget. */
+ private ConnectionWidget connectionMainWidget;
+
+
+ /**
+ * Creates a new instance of SelectConnectionDialog.
+ *
+ * @param parentShell the parent shell
+ * @param title the title
+ * @param initialBrowserConnection the initial browser connection
+ */
+ public SelectBrowserConnectionDialog( Shell parentShell, String title, IBrowserConnection initialBrowserConnection )
+ {
+ super( parentShell );
+ super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+ this.title = title;
+ this.initialBrowserConnection = initialBrowserConnection;
+ this.selectedBrowserConnection = null;
+ }
+
+
+ /**
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell( Shell shell )
+ {
+ super.configureShell( shell );
+ shell.setText( title );
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#close()
+ */
+ public boolean close()
+ {
+ if ( connectionMainWidget != null )
+ {
+ connectionConfiguration.dispose();
+ connectionConfiguration = null;
+ connectionActionGroup.deactivateGlobalActionHandlers();
+ connectionActionGroup.dispose();
+ connectionActionGroup = null;
+ connectionUniversalListener.dispose();
+ connectionUniversalListener = null;
+ connectionMainWidget.dispose();
+ connectionMainWidget = null;
+ }
+ return super.close();
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed()
+ {
+ selectedBrowserConnection = initialBrowserConnection;
+ super.okPressed();
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#cancelPressed()
+ */
+ protected void cancelPressed()
+ {
+ selectedBrowserConnection = null;
+ super.cancelPressed();
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ protected void createButtonsForButtonBar( Composite parent )
+ {
+ createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+ createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea( Composite parent )
+ {
+ Composite composite = ( Composite ) super.createDialogArea( parent );
+ GridLayout gl = new GridLayout();
+ composite.setLayout( gl );
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+ gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2 );
+ composite.setLayoutData( gd );
+
+ // create configuration
+ connectionConfiguration = new ConnectionConfiguration();
+
+ // create main widget
+ connectionMainWidget = new ConnectionWidget( connectionConfiguration, null );
+ connectionMainWidget.createWidget( composite );
+ connectionMainWidget.setInput( ConnectionCorePlugin.getDefault().getConnectionFolderManager() );
+
+ // create actions and context menu (and register global actions)
+ connectionActionGroup = new ConnectionActionGroup( connectionMainWidget, connectionConfiguration );
+ connectionActionGroup.fillToolBar( connectionMainWidget.getToolBarManager() );
+ connectionActionGroup.fillMenu( connectionMainWidget.getMenuManager() );
+ connectionActionGroup.fillContextMenu( connectionMainWidget.getContextMenuManager() );
+ connectionActionGroup.activateGlobalActionHandlers();
+
+ // create the listener
+ connectionUniversalListener = new ConnectionUniversalListener( connectionMainWidget.getViewer() );
+
+ connectionMainWidget.getViewer().addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ if ( !event.getSelection().isEmpty() )
+ {
+ Object o = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
+ if ( o instanceof Connection )
+ {
+ Connection connection = ( Connection ) o;
+ IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
+ .getBrowserConnection( connection );
+ initialBrowserConnection = browserConnection;
+
+ }
+ }
+ }
+ } );
+
+ connectionMainWidget.getViewer().addDoubleClickListener( new IDoubleClickListener()
+ {
+ public void doubleClick( DoubleClickEvent event )
+ {
+ if ( !event.getSelection().isEmpty() )
+ {
+ Object o = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
+ if ( o instanceof Connection )
+ {
+ Connection connection = ( Connection ) o;
+ IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
+ .getBrowserConnection( connection );
+ initialBrowserConnection = browserConnection;
+ okPressed();
+ }
+ }
+ }
+ } );
+
+ if ( initialBrowserConnection != null )
+ {
+ Connection connection = initialBrowserConnection.getConnection();
+ connectionMainWidget.getViewer().reveal( connection );
+ connectionMainWidget.getViewer().setSelection( new StructuredSelection( connection ), true );
+ }
+
+ applyDialogFont( composite );
+
+ connectionMainWidget.setFocus();
+
+ return composite;
+
+ }
+
+
+ /**
+ * Gets the selected browser connection or null if the dialog was canceled.
+ *
+ * @return the selected browser connection or null if the dialog was canceled
+ */
+ public IBrowserConnection getSelectedBrowserConnection()
+ {
+ return selectedBrowserConnection;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/SelectBrowserConnectionDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/SelectEntryDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/SelectEntryDialog.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/SelectEntryDialog.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/SelectEntryDialog.java Mon Nov 5 08:48:35 2007
@@ -0,0 +1,229 @@
+/*
+ * 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.common.dialogs;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserActionGroup;
+import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserConfiguration;
+import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserUniversalListener;
+import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserWidget;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+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.Shell;
+
+
+/**
+ * Dialog to select an entry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SelectEntryDialog extends Dialog
+{
+
+ /** The dialog title. */
+ private String title;
+
+ /** The root entry. */
+ private IEntry rootEntry;
+
+ /** The initial entry. */
+ private IEntry initialEntry;
+
+ /** The selected entry. */
+ private IEntry selectedEntry;
+
+ /** The browser configuration. */
+ private BrowserConfiguration browserConfiguration;
+
+ /** The browser universal listener. */
+ private BrowserUniversalListener browserUniversalListener;
+
+ /** The browser action group. */
+ private BrowserActionGroup browserActionGroup;
+
+ /** The browser widget. */
+ private BrowserWidget browserWidget;
+
+
+ /**
+ * Creates a new instance of SelectEntryDialog.
+ *
+ * @param parentShell the parent shell
+ * @param title the title
+ * @param rootEntry the root entry
+ * @param initialEntry the initial entry
+ */
+ public SelectEntryDialog( Shell parentShell, String title, IEntry rootEntry, IEntry initialEntry )
+ {
+ super( parentShell );
+ super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+ this.title = title;
+ this.rootEntry = rootEntry;
+ this.initialEntry = initialEntry;
+ this.selectedEntry = null;
+ }
+
+
+ /**
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell( Shell shell )
+ {
+ super.configureShell( shell );
+ shell.setText( title );
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#close()
+ */
+ public boolean close()
+ {
+ if ( browserWidget != null )
+ {
+ browserConfiguration.dispose();
+ browserConfiguration = null;
+ browserActionGroup.deactivateGlobalActionHandlers();
+ browserActionGroup.dispose();
+ browserActionGroup = null;
+ browserUniversalListener.dispose();
+ browserUniversalListener = null;
+ browserWidget.dispose();
+ browserWidget = null;
+ }
+ return super.close();
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed()
+ {
+ selectedEntry = initialEntry;
+ super.okPressed();
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#cancelPressed()
+ */
+ protected void cancelPressed()
+ {
+ selectedEntry = null;
+ super.cancelPressed();
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ protected void createButtonsForButtonBar( Composite parent )
+ {
+ createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+ createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea( Composite parent )
+ {
+ Composite composite = ( Composite ) super.createDialogArea( parent );
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+ gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+ composite.setLayoutData( gd );
+
+ // create configuration
+ browserConfiguration = new BrowserConfiguration();
+
+ // create main widget
+ browserWidget = new BrowserWidget( browserConfiguration, null );
+ browserWidget.createWidget( composite );
+ browserWidget.setInput( new IEntry[]
+ { rootEntry } );
+
+ // create actions and context menu (and register global actions)
+ browserActionGroup = new BrowserActionGroup( browserWidget, browserConfiguration );
+ browserActionGroup.fillToolBar( browserWidget.getToolBarManager() );
+ browserActionGroup.fillMenu( browserWidget.getMenuManager() );
+ browserActionGroup.fillContextMenu( browserWidget.getContextMenuManager() );
+ browserActionGroup.activateGlobalActionHandlers();
+
+ // create the listener
+ browserUniversalListener = new BrowserUniversalListener( browserWidget.getViewer() );
+
+ browserWidget.getViewer().addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ if ( !event.getSelection().isEmpty() )
+ {
+ Object o = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
+ if ( o instanceof IEntry )
+ {
+ initialEntry = ( IEntry ) o;
+ }
+ }
+ }
+ } );
+
+ browserWidget.getViewer().expandToLevel( 2 );
+ if ( initialEntry != null )
+ {
+ IEntry entry = this.initialEntry;
+ browserWidget.getViewer().reveal( entry );
+ browserWidget.getViewer().refresh( entry, true );
+ browserWidget.getViewer().setSelection( new StructuredSelection( entry ), true );
+ browserWidget.getViewer().setSelection( new StructuredSelection( entry ), true );
+ }
+
+ applyDialogFont( composite );
+
+ browserWidget.setFocus();
+
+ return composite;
+ }
+
+
+ /**
+ * Gets the selected entry.
+ *
+ * @return the selected entry
+ */
+ public IEntry getSelectedEntry()
+ {
+ return selectedEntry;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/SelectEntryDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/SelectReferralConnectionDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/SelectReferralConnectionDialog.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/SelectReferralConnectionDialog.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/SelectReferralConnectionDialog.java Mon Nov 5 08:48:35 2007
@@ -0,0 +1,220 @@
+/*
+ * 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.common.dialogs;
+
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionActionGroup;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionConfiguration;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionUniversalListener;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionWidget;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.URL;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+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.Shell;
+
+
+public class SelectReferralConnectionDialog extends Dialog
+{
+
+ private String title;
+
+ private URL referralUrl;
+
+ private IBrowserConnection selectedConnection;
+
+ private ConnectionConfiguration configuration;
+
+ private ConnectionUniversalListener universalListener;
+
+ private ConnectionActionGroup actionGroup;
+
+ private ConnectionWidget mainWidget;
+
+
+ public SelectReferralConnectionDialog( Shell parentShell, URL referralUrl )
+ {
+ super( parentShell );
+ super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+ this.title = "Select Referral Connection";
+ this.referralUrl = referralUrl;
+ this.selectedConnection = null;
+ }
+
+
+ protected void configureShell( Shell shell )
+ {
+ super.configureShell( shell );
+ shell.setText( title );
+ }
+
+
+ public boolean close()
+ {
+ if ( this.mainWidget != null )
+ {
+ this.configuration.dispose();
+ this.configuration = null;
+ this.actionGroup.deactivateGlobalActionHandlers();
+ this.actionGroup.dispose();
+ this.actionGroup = null;
+ this.universalListener.dispose();
+ this.universalListener = null;
+ this.mainWidget.dispose();
+ this.mainWidget = null;
+ }
+ return super.close();
+ }
+
+
+ protected void okPressed()
+ {
+ super.okPressed();
+ }
+
+
+ protected void cancelPressed()
+ {
+ this.selectedConnection = null;
+ super.cancelPressed();
+ }
+
+
+ protected void createButtonsForButtonBar( Composite parent )
+ {
+ createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+ createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+ }
+
+
+ protected Control createDialogArea( Composite parent )
+ {
+
+ Composite composite = ( Composite ) super.createDialogArea( parent );
+ GridLayout gl = new GridLayout();
+ composite.setLayout( gl );
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+ gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2 );
+ composite.setLayoutData( gd );
+
+ BaseWidgetUtils.createWrappedLabeledText( composite, "Please select a connection to handle referral "
+ + referralUrl, 1 );
+
+ // create configuration
+ this.configuration = new ConnectionConfiguration();
+
+ // create main widget
+ this.mainWidget = new ConnectionWidget( this.configuration, null );
+ this.mainWidget.createWidget( composite );
+ this.mainWidget.setInput( ConnectionCorePlugin.getDefault().getConnectionFolderManager() );
+
+ // create actions and context menu (and register global actions)
+ this.actionGroup = new ConnectionActionGroup( this.mainWidget, this.configuration );
+ this.actionGroup.fillToolBar( this.mainWidget.getToolBarManager() );
+ this.actionGroup.fillMenu( this.mainWidget.getMenuManager() );
+ this.actionGroup.fillContextMenu( this.mainWidget.getContextMenuManager() );
+ this.actionGroup.activateGlobalActionHandlers();
+
+ // create the listener
+ this.universalListener = new ConnectionUniversalListener( this.mainWidget.getViewer() );
+
+ this.mainWidget.getViewer().addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ if ( !event.getSelection().isEmpty() )
+ {
+ Object o = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
+ if ( o instanceof Connection )
+ {
+ Connection connection = ( Connection ) o;
+ IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
+ .getBrowserConnection( connection );
+ selectedConnection = browserConnection;
+ }
+ }
+ }
+ } );
+
+ this.mainWidget.getViewer().addDoubleClickListener( new IDoubleClickListener()
+ {
+ public void doubleClick( DoubleClickEvent event )
+ {
+ if ( !event.getSelection().isEmpty() )
+ {
+ Object o = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
+ if ( o instanceof Connection )
+ {
+ Connection connection = ( Connection ) o;
+ IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
+ .getBrowserConnection( connection );
+ selectedConnection = browserConnection;
+ }
+ }
+ }
+ } );
+
+ if ( this.referralUrl != null )
+ {
+ IBrowserConnection[] connections = BrowserCorePlugin.getDefault().getConnectionManager().getBrowserConnections();
+ for ( int i = 0; i < connections.length; i++ )
+ {
+ IBrowserConnection connection = connections[i];
+ URL connectionUrl = connection.getUrl();
+ if ( connectionUrl != null && referralUrl.toString().startsWith( connectionUrl.toString() ) )
+ {
+ this.mainWidget.getViewer().reveal( connection );
+ this.mainWidget.getViewer().setSelection( new StructuredSelection( connection.getConnection() ), true );
+ }
+ }
+ }
+
+ applyDialogFont( composite );
+
+ this.mainWidget.setFocus();
+
+ return composite;
+
+ }
+
+
+ public IBrowserConnection getReferralConnection()
+ {
+ return this.selectedConnection;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/SelectReferralConnectionDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/TextDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/TextDialog.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/TextDialog.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/TextDialog.java Mon Nov 5 08:48:35 2007
@@ -0,0 +1,139 @@
+/*
+ * 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.common.dialogs;
+
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+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.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+/**
+ * Dialog with an text area.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class TextDialog extends Dialog
+{
+
+ /** The dialog title. */
+ private static final String DIALOG_TITLE = "Text Editor";
+
+ /** The initial value. */
+ private String initialValue;
+
+ /** The return value. */
+ private String returnValue;
+
+ /** The text area. */
+ private Text text;
+
+
+ /**
+ * Creates a new instance of TextDialog.
+ *
+ * @param parentShell the parent shell
+ * @param initialValue the initial value
+ */
+ public TextDialog( Shell parentShell, String initialValue )
+ {
+ super( parentShell );
+ super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+ this.initialValue = initialValue;
+ this.returnValue = null;
+ }
+
+
+ /**
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell( Shell shell )
+ {
+ super.configureShell( shell );
+ shell.setText( DIALOG_TITLE );
+ shell.setImage( BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_TEXTEDITOR ) );
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ protected void createButtonsForButtonBar( Composite parent )
+ {
+ createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+ createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed()
+ {
+ returnValue = text.getText();
+ super.okPressed();
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea( Composite parent )
+ {
+ // create composite
+ Composite composite = ( Composite ) super.createDialogArea( parent );
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ composite.setLayoutData( gd );
+
+ // text widget
+ text = new Text( composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL );
+ text.setText( this.initialValue );
+ // GridData gd = new GridData(GridData.GRAB_HORIZONTAL |
+ // GridData.HORIZONTAL_ALIGN_FILL);
+ gd = new GridData( GridData.FILL_BOTH );
+ gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+ gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2 );
+ text.setLayoutData( gd );
+
+ applyDialogFont( composite );
+ return composite;
+ }
+
+
+ /**
+ * Gets the text.
+ *
+ * @return the text
+ */
+ public String getText()
+ {
+ return returnValue;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/TextDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/AttributeDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/AttributeDialog.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/AttributeDialog.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/AttributeDialog.java Mon Nov 5 08:48:35 2007
@@ -0,0 +1,108 @@
+/*
+ * 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.common.dialogs.preferences;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.BinaryAttribute;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class AttributeDialog extends Dialog
+{
+
+ private BinaryAttribute currentAttribute;
+
+ private String[] attributeTypesAndOids;
+
+ private BinaryAttribute returnAttribute;
+
+ private Combo typeOrOidCombo;
+
+
+ public AttributeDialog( Shell parentShell, BinaryAttribute currentAttribute, String[] attributeNamesAndOids )
+ {
+ super( parentShell );
+ this.currentAttribute = currentAttribute;
+ this.attributeTypesAndOids = attributeNamesAndOids;
+
+ this.returnAttribute = null;
+ }
+
+
+ protected void configureShell( Shell newShell )
+ {
+ super.configureShell( newShell );
+ newShell.setText( "Select Attribute Type or OID" );
+ }
+
+
+ protected void okPressed()
+ {
+ this.returnAttribute = new BinaryAttribute( typeOrOidCombo.getText() );
+ super.okPressed();
+ }
+
+
+ protected Control createDialogArea( Composite parent )
+ {
+
+ Composite composite = ( Composite ) super.createDialogArea( parent );
+
+ Composite c = BaseWidgetUtils.createColumnContainer( composite, 2, 1 );
+ BaseWidgetUtils.createLabel( c, "Attribute Type or OID:", 1 );
+ this.typeOrOidCombo = BaseWidgetUtils.createCombo( c, this.attributeTypesAndOids, -1, 1 );
+ if ( this.currentAttribute != null )
+ {
+ this.typeOrOidCombo.setText( currentAttribute.getAttributeNumericOidOrName() );
+ }
+ this.typeOrOidCombo.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ validate();
+ }
+ } );
+
+ return composite;
+ }
+
+
+ private void validate()
+ {
+ super.getButton( IDialogConstants.OK_ID ).setEnabled( !"".equals( this.typeOrOidCombo.getText() ) );
+ }
+
+
+ public BinaryAttribute getAttribute()
+ {
+ return returnAttribute;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/AttributeDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/AttributeValueEditorDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/AttributeValueEditorDialog.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/AttributeValueEditorDialog.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/AttributeValueEditorDialog.java Mon Nov 5 08:48:35 2007
@@ -0,0 +1,146 @@
+/*
+ * 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.common.dialogs.preferences;
+
+
+import java.util.Iterator;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.AttributeValueProviderRelation;
+import org.apache.directory.studio.valueeditors.ValueEditorManager.ValueEditorExtension;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class AttributeValueEditorDialog extends Dialog
+{
+
+ private AttributeValueProviderRelation relation;
+
+ private SortedMap<String, ValueEditorExtension> class2ValueEditorProxyMap;
+
+ private String[] attributeTypesAndOids;
+
+ private SortedMap<String, String> vpName2classMap;
+
+ private AttributeValueProviderRelation returnRelation;
+
+ private Combo typeOrOidCombo;
+
+ private Combo valueEditorCombo;
+
+
+ public AttributeValueEditorDialog( Shell parentShell, AttributeValueProviderRelation relation,
+ SortedMap<String, ValueEditorExtension> class2ValueEditorProxyMap, String[] attributeTypesAndOids )
+ {
+ super( parentShell );
+ this.relation = relation;
+ this.class2ValueEditorProxyMap = class2ValueEditorProxyMap;
+ this.attributeTypesAndOids = attributeTypesAndOids;
+
+ this.returnRelation = null;
+
+ this.vpName2classMap = new TreeMap<String, String>();
+ for ( Iterator<ValueEditorExtension> it = this.class2ValueEditorProxyMap.values().iterator(); it.hasNext(); )
+ {
+ ValueEditorExtension vp = it.next();
+ vpName2classMap.put( vp.name, vp.className );
+ }
+ }
+
+
+ protected void configureShell( Shell newShell )
+ {
+ super.configureShell( newShell );
+ newShell.setText( "Attribute Value Editor" );
+ }
+
+
+ protected void okPressed()
+ {
+ this.returnRelation = new AttributeValueProviderRelation( this.typeOrOidCombo.getText(), this.vpName2classMap
+ .get( this.valueEditorCombo.getText() ) );
+ super.okPressed();
+ }
+
+
+ protected Control createDialogArea( Composite parent )
+ {
+
+ Composite composite = ( Composite ) super.createDialogArea( parent );
+
+ Composite c = BaseWidgetUtils.createColumnContainer( composite, 2, 1 );
+ BaseWidgetUtils.createLabel( c, "Attribute Type or OID:", 1 );
+ this.typeOrOidCombo = BaseWidgetUtils.createCombo( c, this.attributeTypesAndOids, -1, 1 );
+ if ( this.relation != null && this.relation.getAttributeNumericOidOrType() != null )
+ {
+ this.typeOrOidCombo.setText( this.relation.getAttributeNumericOidOrType() );
+ }
+ this.typeOrOidCombo.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ validate();
+ }
+ } );
+
+ BaseWidgetUtils.createLabel( c, "Value Editor:", 1 );
+ this.valueEditorCombo = BaseWidgetUtils.createReadonlyCombo( c, vpName2classMap.keySet()
+ .toArray( new String[0] ), -1, 1 );
+ if ( this.relation != null && this.relation.getValueProviderClassname() != null
+ && this.class2ValueEditorProxyMap.containsKey( this.relation.getValueProviderClassname() ) )
+ {
+ this.valueEditorCombo.setText( ( this.class2ValueEditorProxyMap.get( this.relation
+ .getValueProviderClassname() ) ).name );
+ }
+ this.valueEditorCombo.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ validate();
+ }
+ } );
+
+ return composite;
+ }
+
+
+ private void validate()
+ {
+ super.getButton( IDialogConstants.OK_ID ).setEnabled(
+ !"".equals( this.valueEditorCombo.getText() ) && !"".equals( this.typeOrOidCombo.getText() ) );
+ }
+
+
+ public AttributeValueProviderRelation getRelation()
+ {
+ return returnRelation;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/AttributeValueEditorDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/AttributesPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/AttributesPreferencePage.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/AttributesPreferencePage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/AttributesPreferencePage.java Mon Nov 5 08:48:35 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.common.dialogs.preferences;
+
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.eclipse.jface.preference.ColorSelector;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+public class AttributesPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+
+ private final String[] ATTRIBUTE_TYPES = new String[]
+ { "Objectclass attribute:", "Must attributes:", "May attributes:", "Operational attributes:" };
+
+ private final String[] ATTRIBUTE_FONT_CONSTANTS = new String[]
+ { BrowserCommonConstants.PREFERENCE_OBJECTCLASS_FONT, BrowserCommonConstants.PREFERENCE_MUSTATTRIBUTE_FONT,
+ BrowserCommonConstants.PREFERENCE_MAYATTRIBUTE_FONT, BrowserCommonConstants.PREFERENCE_OPERATIONALATTRIBUTE_FONT };
+
+ private final String[] ATTRIBUTE_COLOR_CONSTANTS = new String[]
+ { BrowserCommonConstants.PREFERENCE_OBJECTCLASS_COLOR, BrowserCommonConstants.PREFERENCE_MUSTATTRIBUTE_COLOR,
+ BrowserCommonConstants.PREFERENCE_MAYATTRIBUTE_COLOR, BrowserCommonConstants.PREFERENCE_OPERATIONALATTRIBUTE_COLOR };
+
+ private Label[] attributeTypeLabels = new Label[ATTRIBUTE_TYPES.length];
+
+ private ColorSelector[] attributeColorSelectors = new ColorSelector[ATTRIBUTE_TYPES.length];
+
+ private Button[] attributeBoldButtons = new Button[ATTRIBUTE_TYPES.length];
+
+ private Button[] attributeItalicButtons = new Button[ATTRIBUTE_TYPES.length];
+
+ private Button showRawValuesButton;
+
+
+ public AttributesPreferencePage()
+ {
+ super( "Attributes" );
+ super.setPreferenceStore( BrowserCommonActivator.getDefault().getPreferenceStore() );
+ super.setDescription( "General settings for attributes:" );
+ }
+
+
+ public void init( IWorkbench workbench )
+ {
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ Composite composite = new Composite( parent, SWT.NONE );
+ GridLayout layout = new GridLayout( 1, false );
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.marginLeft = 0;
+ layout.marginRight = 0;
+ layout.marginTop = 0;
+ layout.marginBottom = 0;
+ composite.setLayout( layout );
+ composite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ Group colorsAndFontsGroup = BaseWidgetUtils.createGroup( composite, "Attribute Colors and Fonts", 1 );
+ colorsAndFontsGroup.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+ Composite colorsAndFontsComposite = BaseWidgetUtils.createColumnContainer( colorsAndFontsGroup, 4, 1 );
+ for ( int i = 0; i < ATTRIBUTE_TYPES.length; i++ )
+ {
+ final int index = i;
+
+ attributeTypeLabels[i] = BaseWidgetUtils.createLabel( colorsAndFontsComposite, ATTRIBUTE_TYPES[i], 1 );
+ attributeTypeLabels[i].setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+ attributeColorSelectors[i] = new ColorSelector( colorsAndFontsComposite );
+ attributeBoldButtons[i] = BaseWidgetUtils.createCheckbox( colorsAndFontsComposite, "Bold", 1 );
+ attributeItalicButtons[i] = BaseWidgetUtils.createCheckbox( colorsAndFontsComposite, "Italic", 1 );
+
+ FontData[] fontDatas = PreferenceConverter.getFontDataArray( BrowserCommonActivator.getDefault()
+ .getPreferenceStore(), ATTRIBUTE_FONT_CONSTANTS[i] );
+ RGB rgb = PreferenceConverter.getColor( BrowserCommonActivator.getDefault().getPreferenceStore(),
+ ATTRIBUTE_COLOR_CONSTANTS[i] );
+ setColorsAndFonts( index, fontDatas, rgb );
+ }
+
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ showRawValuesButton = BaseWidgetUtils.createCheckbox( composite, "Show raw values", 1 );
+ showRawValuesButton.setSelection( getPreferenceStore().getBoolean(
+ BrowserCommonConstants.PREFERENCE_SHOW_RAW_VALUES ) );
+
+ applyDialogFont( composite );
+ return composite;
+ }
+
+
+ private void setColorsAndFonts( int index, FontData[] fontDatas, RGB rgb )
+ {
+ boolean bold = isBold( fontDatas );
+ boolean italic = isItalic( fontDatas );
+ attributeColorSelectors[index].setColorValue( rgb );
+ attributeBoldButtons[index].setSelection( bold );
+ attributeItalicButtons[index].setSelection( italic );
+ }
+
+
+ private void setFontData( FontData[] fontDatas, Button boldButton, Button italicButton )
+ {
+ for ( int j = 0; j < fontDatas.length; j++ )
+ {
+ int style = SWT.NORMAL;
+ if ( boldButton.getSelection() )
+ style |= SWT.BOLD;
+ if ( italicButton.getSelection() )
+ style |= SWT.ITALIC;
+ fontDatas[j].setStyle( style );
+ }
+ }
+
+
+ private boolean isBold( FontData[] fontDatas )
+ {
+ boolean bold = false;
+ for ( int j = 0; j < fontDatas.length; j++ )
+ {
+ if ( ( fontDatas[j].getStyle() & SWT.BOLD ) != SWT.NORMAL )
+ bold = true;
+ }
+ return bold;
+ }
+
+
+ private boolean isItalic( FontData[] fontDatas )
+ {
+ boolean italic = false;
+ for ( int j = 0; j < fontDatas.length; j++ )
+ {
+ if ( ( fontDatas[j].getStyle() & SWT.ITALIC ) != SWT.NORMAL )
+ italic = true;
+ }
+ return italic;
+ }
+
+
+ public boolean performOk()
+ {
+
+ for ( int i = 0; i < ATTRIBUTE_TYPES.length; i++ )
+ {
+ FontData[] fontDatas = PreferenceConverter.getFontDataArray( BrowserCommonActivator.getDefault()
+ .getPreferenceStore(), ATTRIBUTE_FONT_CONSTANTS[i] );
+ setFontData( fontDatas, this.attributeBoldButtons[i], this.attributeItalicButtons[i] );
+ RGB rgb = attributeColorSelectors[i].getColorValue();
+ PreferenceConverter.setValue( BrowserCommonActivator.getDefault().getPreferenceStore(),
+ ATTRIBUTE_FONT_CONSTANTS[i], fontDatas );
+ PreferenceConverter.setValue( BrowserCommonActivator.getDefault().getPreferenceStore(),
+ ATTRIBUTE_COLOR_CONSTANTS[i], rgb );
+ }
+
+ getPreferenceStore().setValue( BrowserCommonConstants.PREFERENCE_SHOW_RAW_VALUES,
+ this.showRawValuesButton.getSelection() );
+
+ return true;
+ }
+
+
+ protected void performDefaults()
+ {
+
+ for ( int i = 0; i < ATTRIBUTE_TYPES.length; i++ )
+ {
+ FontData[] fontDatas = PreferenceConverter.getDefaultFontDataArray( BrowserCommonActivator.getDefault()
+ .getPreferenceStore(), ATTRIBUTE_FONT_CONSTANTS[i] );
+ RGB rgb = PreferenceConverter.getDefaultColor( BrowserCommonActivator.getDefault().getPreferenceStore(),
+ ATTRIBUTE_COLOR_CONSTANTS[i] );
+ setColorsAndFonts( i, fontDatas, rgb );
+ }
+
+ showRawValuesButton.setSelection( getPreferenceStore().getDefaultBoolean(
+ BrowserCommonConstants.PREFERENCE_SHOW_RAW_VALUES ) );
+
+ super.performDefaults();
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/AttributesPreferencePage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/BinaryAttributesAndSyntaxesPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/BinaryAttributesAndSyntaxesPreferencePage.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/BinaryAttributesAndSyntaxesPreferencePage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/BinaryAttributesAndSyntaxesPreferencePage.java Mon Nov 5 08:48:35 2007
@@ -0,0 +1,538 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.ldapbrowser.common.dialogs.preferences;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
+import org.apache.directory.studio.ldapbrowser.core.BrowserConnectionManager;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.AttributeTypeDescription;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.BinaryAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.BinarySyntax;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.LdapSyntaxDescription;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+public class BinaryAttributesAndSyntaxesPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+
+ private SortedMap attributeOid2AtdMap;
+
+ private SortedMap attributeNames2AtdMap;
+
+ private String[] attributeNamesAndOids;
+
+ private SortedMap syntaxOid2LsdMap;
+
+ private SortedMap syntaxDesc2LsdMap;
+
+ private String[] syntaxOids;
+
+ private List attributeList;
+
+ private TableViewer attributeViewer;
+
+ private Button attributeAddButton;
+
+ private Button attributeEditButton;
+
+ private Button attributeRemoveButton;
+
+ private List syntaxList;
+
+ private TableViewer syntaxViewer;
+
+ private Button syntaxAddButton;
+
+ private Button syntaxEditButton;
+
+ private Button syntaxRemoveButton;
+
+
+ public BinaryAttributesAndSyntaxesPreferencePage()
+ {
+ super();
+ super.setDescription( "Specify attributes to handle as binary:" );
+ }
+
+
+ public void init( IWorkbench workbench )
+ {
+ }
+
+
+ protected Control createContents( Composite parent )
+ {
+
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
+ composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+ // init available attribute types
+ this.attributeNames2AtdMap = new TreeMap();
+ this.attributeOid2AtdMap = new TreeMap();
+ BrowserConnectionManager cm = BrowserCorePlugin.getDefault().getConnectionManager();
+ IBrowserConnection[] connections = cm.getBrowserConnections();
+ for ( int i = 0; i < connections.length; i++ )
+ {
+ Schema schema = connections[i].getSchema();
+ if ( schema != null )
+ {
+ createAttributeMaps( schema );
+ }
+ }
+ createAttributeMaps( Schema.DEFAULT_SCHEMA );
+ this.attributeNamesAndOids = new String[this.attributeNames2AtdMap.size() + this.attributeOid2AtdMap.size()];
+ System.arraycopy( this.attributeNames2AtdMap.keySet().toArray(), 0, this.attributeNamesAndOids, 0,
+ this.attributeNames2AtdMap.size() );
+ System.arraycopy( this.attributeOid2AtdMap.keySet().toArray(), 0, this.attributeNamesAndOids,
+ this.attributeNames2AtdMap.size(), this.attributeOid2AtdMap.size() );
+
+ // init available syntaxes
+ this.syntaxOid2LsdMap = new TreeMap();
+ this.syntaxDesc2LsdMap = new TreeMap();
+ for ( int i = 0; i < connections.length; i++ )
+ {
+ Schema schema = connections[i].getSchema();
+ if ( schema != null )
+ {
+ createSyntaxMaps( schema );
+ }
+ }
+ createSyntaxMaps( Schema.DEFAULT_SCHEMA );
+ this.syntaxOids = new String[this.syntaxOid2LsdMap.size()];
+ System
+ .arraycopy( this.syntaxOid2LsdMap.keySet().toArray(), 0, this.syntaxOids, 0, this.syntaxOid2LsdMap.size() );
+
+ // create attribute contents
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ createAttributeContents( composite );
+ attributeList = new ArrayList( Arrays.asList( BrowserCorePlugin.getDefault().getCorePreferences()
+ .getBinaryAttributes() ) );
+ attributeViewer.setInput( this.attributeList );
+ attributeViewer.getTable().getColumn( 0 ).pack();
+ // attributeViewer.getTable().getColumn(1).pack();
+ attributeViewer.getTable().pack();
+
+ // create syntax contents
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ createSyntaxContents( composite );
+ syntaxList = new ArrayList( Arrays.asList( BrowserCorePlugin.getDefault().getCorePreferences()
+ .getBinarySyntaxes() ) );
+ syntaxViewer.setInput( this.syntaxList );
+ syntaxViewer.getTable().getColumn( 0 ).pack();
+ // syntaxViewer.getTable().getColumn(1).pack();
+ syntaxViewer.getTable().pack();
+
+ return composite;
+ }
+
+
+ private void createAttributeMaps( Schema schema )
+ {
+ AttributeTypeDescription[] atds = schema.getAttributeTypeDescriptions();
+ for ( int i = 0; i < atds.length; i++ )
+ {
+
+ attributeOid2AtdMap.put( atds[i].getNumericOID(), atds[i] );
+
+ String[] names = atds[i].getNames();
+ for ( int j = 0; j < names.length; j++ )
+ {
+ attributeNames2AtdMap.put( names[j], atds[i] );
+ }
+
+ }
+ }
+
+
+ private void createSyntaxMaps( Schema schema )
+ {
+ LdapSyntaxDescription[] lsds = schema.getLdapSyntaxDescriptions();
+ for ( int i = 0; i < lsds.length; i++ )
+ {
+
+ syntaxOid2LsdMap.put( lsds[i].getNumericOID(), lsds[i] );
+
+ if ( lsds[i].getDesc() != null )
+ {
+ syntaxDesc2LsdMap.put( lsds[i].getDesc(), lsds[i] );
+ }
+
+ }
+ }
+
+
+ private void createAttributeContents( Composite parent )
+ {
+
+ BaseWidgetUtils.createLabel( parent, "Binary Attributes", 1 );
+
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 2, 1 );
+ composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ Composite listComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+ listComposite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ Composite buttonComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+ buttonComposite.setLayoutData( new GridData( GridData.VERTICAL_ALIGN_BEGINNING ) );
+
+ Table table = new Table( listComposite, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION );
+ GridData data = new GridData( GridData.FILL_BOTH );
+ data.widthHint = 360;
+ data.heightHint = convertHeightInCharsToPixels( 10 );
+ table.setLayoutData( data );
+ table.setHeaderVisible( true );
+ table.setLinesVisible( true );
+ attributeViewer = new TableViewer( table );
+
+ TableColumn c1 = new TableColumn( table, SWT.NONE );
+ c1.setText( "Attribute" );
+ c1.setWidth( 300 );
+ TableColumn c2 = new TableColumn( table, SWT.NONE );
+ c2.setText( "Alias" );
+ c2.setWidth( 60 );
+
+ attributeViewer.setColumnProperties( new String[]
+ { "Attribute" } );
+ attributeViewer.setContentProvider( new ArrayContentProvider() );
+ attributeViewer.setLabelProvider( new AttributeLabelProvider() );
+
+ attributeViewer.addDoubleClickListener( new IDoubleClickListener()
+ {
+ public void doubleClick( DoubleClickEvent event )
+ {
+ editAttribute();
+ }
+ } );
+
+ attributeAddButton = BaseWidgetUtils.createButton( buttonComposite, "Add...", 1 );
+ attributeAddButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ addAttribute();
+ }
+ } );
+ attributeEditButton = BaseWidgetUtils.createButton( buttonComposite, "Edit...", 1 );
+ attributeEditButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ editAttribute();
+ }
+ } );
+ attributeRemoveButton = BaseWidgetUtils.createButton( buttonComposite, "Remove", 1 );
+ attributeRemoveButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ removeAttribute();
+ }
+ } );
+
+ // c1.pack();
+ // c2.pack();
+ // table.pack();
+ }
+
+
+ private void createSyntaxContents( Composite parent )
+ {
+
+ BaseWidgetUtils.createLabel( parent, "Binary Syntaxes", 1 );
+
+ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 2, 1 );
+ composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ Composite listComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+ listComposite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ Composite buttonComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+ buttonComposite.setLayoutData( new GridData( GridData.VERTICAL_ALIGN_BEGINNING ) );
+
+ Table table = new Table( listComposite, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION );
+ GridData data = new GridData( GridData.FILL_BOTH );
+ data.widthHint = 360;
+ data.heightHint = convertHeightInCharsToPixels( 10 );
+ table.setLayoutData( data );
+ table.setHeaderVisible( true );
+ table.setLinesVisible( true );
+ syntaxViewer = new TableViewer( table );
+
+ TableColumn c1 = new TableColumn( table, SWT.NONE );
+ c1.setText( "Syntax" );
+ c1.setWidth( 300 );
+ TableColumn c2 = new TableColumn( table, SWT.NONE );
+ c2.setText( "Desc" );
+ c2.setWidth( 60 );
+
+ syntaxViewer.setColumnProperties( new String[]
+ { "Syntax" } );
+ syntaxViewer.setContentProvider( new ArrayContentProvider() );
+ syntaxViewer.setLabelProvider( new SyntaxLabelProvider() );
+
+ syntaxViewer.addDoubleClickListener( new IDoubleClickListener()
+ {
+ public void doubleClick( DoubleClickEvent event )
+ {
+ editSyntax();
+ }
+ } );
+
+ syntaxAddButton = BaseWidgetUtils.createButton( buttonComposite, "Add...", 1 );
+ syntaxAddButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ addSyntax();
+ }
+ } );
+ syntaxEditButton = BaseWidgetUtils.createButton( buttonComposite, "Edit...", 1 );
+ syntaxEditButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ editSyntax();
+ }
+ } );
+ syntaxRemoveButton = BaseWidgetUtils.createButton( buttonComposite, "Remove", 1 );
+ syntaxRemoveButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ removeSyntax();
+ }
+ } );
+
+ // c1.pack();
+ // c2.pack();
+ // table.pack();
+ }
+
+
+ protected void addAttribute()
+ {
+ AttributeDialog dialog = new AttributeDialog( getShell(), null, this.attributeNamesAndOids );
+ if ( dialog.open() == AttributeValueEditorDialog.OK )
+ {
+ this.attributeList.add( dialog.getAttribute() );
+ this.attributeViewer.refresh();
+ }
+ }
+
+
+ protected void removeAttribute()
+ {
+ Object o = ( ( StructuredSelection ) this.attributeViewer.getSelection() ).getFirstElement();
+ this.attributeList.remove( o );
+ this.attributeViewer.refresh();
+ }
+
+
+ protected void editAttribute()
+ {
+ StructuredSelection sel = ( StructuredSelection ) this.attributeViewer.getSelection();
+ if ( !sel.isEmpty() )
+ {
+ BinaryAttribute attribute = ( BinaryAttribute ) sel.getFirstElement();
+ AttributeDialog dialog = new AttributeDialog( getShell(), attribute, this.attributeNamesAndOids );
+ if ( dialog.open() == AttributeValueEditorDialog.OK )
+ {
+ int index = this.attributeList.indexOf( attribute );
+ this.attributeList.set( index, dialog.getAttribute() );
+ this.attributeViewer.refresh();
+ }
+ }
+ }
+
+
+ protected void addSyntax()
+ {
+ SyntaxDialog dialog = new SyntaxDialog( getShell(), null, this.syntaxOids );
+ if ( dialog.open() == SyntaxValueEditorDialog.OK )
+ {
+ this.syntaxList.add( dialog.getSyntax() );
+ this.syntaxViewer.refresh();
+ }
+ }
+
+
+ protected void removeSyntax()
+ {
+ Object o = ( ( StructuredSelection ) this.syntaxViewer.getSelection() ).getFirstElement();
+ this.syntaxList.remove( o );
+ this.syntaxViewer.refresh();
+ }
+
+
+ protected void editSyntax()
+ {
+ StructuredSelection sel = ( StructuredSelection ) this.syntaxViewer.getSelection();
+ if ( !sel.isEmpty() )
+ {
+ BinarySyntax syntax = ( BinarySyntax ) sel.getFirstElement();
+ SyntaxDialog dialog = new SyntaxDialog( getShell(), syntax, this.syntaxOids );
+ if ( dialog.open() == SyntaxValueEditorDialog.OK )
+ {
+ int index = this.syntaxList.indexOf( syntax );
+ this.syntaxList.set( index, dialog.getSyntax() );
+ this.syntaxViewer.refresh();
+ }
+ }
+ }
+
+
+ public boolean performOk()
+ {
+ BinaryAttribute[] attributes = ( BinaryAttribute[] ) this.attributeList
+ .toArray( new BinaryAttribute[this.attributeList.size()] );
+ BrowserCorePlugin.getDefault().getCorePreferences().setBinaryAttributes( attributes );
+
+ BinarySyntax[] syntaxes = ( BinarySyntax[] ) this.syntaxList.toArray( new BinarySyntax[this.syntaxList.size()] );
+ BrowserCorePlugin.getDefault().getCorePreferences().setBinarySyntaxes( syntaxes );
+
+ return true;
+ }
+
+
+ protected void performDefaults()
+ {
+ this.attributeList.clear();
+ this.attributeList.addAll( Arrays.asList( BrowserCorePlugin.getDefault().getCorePreferences()
+ .getDefaultBinaryAttributes() ) );
+ this.attributeViewer.refresh();
+
+ this.syntaxList.clear();
+ this.syntaxList.addAll( Arrays.asList( BrowserCorePlugin.getDefault().getCorePreferences()
+ .getDefaultBinarySyntaxes() ) );
+ this.syntaxViewer.refresh();
+
+ super.performDefaults();
+ }
+
+ class AttributeLabelProvider extends LabelProvider implements ITableLabelProvider
+ {
+ public String getColumnText( Object obj, int index )
+ {
+ if ( obj instanceof BinaryAttribute )
+ {
+ BinaryAttribute attribute = ( BinaryAttribute ) obj;
+ if ( index == 0 )
+ {
+ return attribute.getAttributeNumericOidOrName();
+ }
+ else if ( index == 1 )
+ {
+ if ( attribute.getAttributeNumericOidOrName() != null )
+ {
+ if ( attributeNames2AtdMap.containsKey( attribute.getAttributeNumericOidOrName() ) )
+ {
+ AttributeTypeDescription atd = ( AttributeTypeDescription ) attributeNames2AtdMap
+ .get( attribute.getAttributeNumericOidOrName() );
+ String s = atd.getNumericOID();
+ for ( int i = 0; i < atd.getNames().length; i++ )
+ {
+ if ( !attribute.getAttributeNumericOidOrName().equals( atd.getNames()[i] ) )
+ {
+ s += ", " + atd.getNames()[i];
+ }
+ }
+ return s;
+ }
+ else if ( attributeOid2AtdMap.containsKey( attribute.getAttributeNumericOidOrName() ) )
+ {
+ AttributeTypeDescription atd = ( AttributeTypeDescription ) attributeOid2AtdMap
+ .get( attribute.getAttributeNumericOidOrName() );
+ return atd.toString();
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+
+ public Image getColumnImage( Object obj, int index )
+ {
+ return null;
+ }
+ }
+
+ class SyntaxLabelProvider extends LabelProvider implements ITableLabelProvider
+ {
+ public String getColumnText( Object obj, int index )
+ {
+ if ( obj instanceof BinarySyntax )
+ {
+ BinarySyntax syntax = ( BinarySyntax ) obj;
+ if ( index == 0 )
+ {
+ return syntax.getSyntaxNumericOid();
+ }
+ else if ( index == 1 )
+ {
+ if ( syntax.getSyntaxNumericOid() != null )
+ {
+ if ( syntaxOid2LsdMap.containsKey( syntax.getSyntaxNumericOid() ) )
+ {
+ LdapSyntaxDescription lsd = ( LdapSyntaxDescription ) syntaxOid2LsdMap.get( syntax
+ .getSyntaxNumericOid() );
+ return lsd.toString();
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+
+ public Image getColumnImage( Object obj, int index )
+ {
+ return null;
+ }
+ }
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/preferences/BinaryAttributesAndSyntaxesPreferencePage.java
------------------------------------------------------------------------------
svn:eol-style = native