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 [7/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/sr...
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/RenameAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/RenameAction.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/RenameAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/RenameAction.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.actions;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.internal.model.BaseDNEntry;
+import org.apache.directory.ldapstudio.browser.core.internal.model.DirectoryMetadataEntry;
+import org.apache.directory.ldapstudio.browser.core.internal.model.RootDSE;
+import org.apache.directory.ldapstudio.browser.core.jobs.RenameEntryJob;
+import org.apache.directory.ldapstudio.browser.core.model.IBookmark;
+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.ISearch;
+import org.apache.directory.ldapstudio.browser.core.model.RDN;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.RenameEntryDialog;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
+
+
+public class RenameAction extends BrowserAction implements ModelModifier
+{
+
+ public RenameAction()
+ {
+ super();
+ }
+
+
+ public String getText()
+ {
+
+ IConnection[] connections = getConnections();
+ IEntry[] entries = getEntries();
+ ISearch[] searches = getSearches();
+ IBookmark[] bookmarks = getBookmarks();
+
+ if ( connections.length == 1 && entries.length == 0 && searches.length == 0 && bookmarks.length == 0 )
+ {
+ return "Rename Connection...";
+ }
+ else if ( entries.length == 1 && connections.length == 0 && searches.length == 0 && bookmarks.length == 0 )
+ {
+ return "Rename Entry...";
+ }
+ else if ( searches.length == 1 && connections.length == 0 && entries.length == 0 && bookmarks.length == 0 )
+ {
+ return "Rename Search...";
+ }
+ else if ( bookmarks.length == 1 && connections.length == 0 && entries.length == 0 && searches.length == 0 )
+ {
+ return "Rename Bookmark...";
+ }
+ else
+ {
+ return "Rename";
+ }
+ }
+
+
+ public ImageDescriptor getImageDescriptor()
+ {
+ return null;
+ }
+
+
+ public String getCommandId()
+ {
+ return IWorkbenchActionDefinitionIds.RENAME;
+ }
+
+
+ public void run()
+ {
+
+ IConnection[] connections = getConnections();
+ IEntry[] entries = getEntries();
+ ISearch[] searches = getSearches();
+ IBookmark[] bookmarks = getBookmarks();
+
+ if ( connections.length == 1 && entries.length == 0 && searches.length == 0 && bookmarks.length == 0 )
+ {
+ renameConnection( connections[0] );
+ }
+ else if ( entries.length == 1 && connections.length == 0 && searches.length == 0 && bookmarks.length == 0 )
+ {
+ renameEntry( entries[0] );
+ }
+ else if ( searches.length == 1 && connections.length == 0 && entries.length == 0 && bookmarks.length == 0 )
+ {
+ renameSearch( searches[0] );
+ }
+ else if ( bookmarks.length == 1 && connections.length == 0 && entries.length == 0 && searches.length == 0 )
+ {
+ renameBookmark( bookmarks[0] );
+ }
+ }
+
+
+ public boolean isEnabled()
+ {
+
+ try
+ {
+ IConnection[] connections = getConnections();
+ IEntry[] entries = getEntries();
+ ISearch[] searches = getSearches();
+ IBookmark[] bookmarks = getBookmarks();
+
+ return connections.length + entries.length + searches.length + bookmarks.length == 1;
+
+ }
+ catch ( Exception e )
+ {
+ return false;
+ }
+ }
+
+
+ protected IConnection[] getConnections()
+ {
+ if ( getSelectedConnections().length == 1 )
+ {
+ return getSelectedConnections();
+ }
+ else
+ {
+ return new IConnection[0];
+ }
+ }
+
+
+ protected void renameConnection( final IConnection connection )
+ {
+ IInputValidator validator = new IInputValidator()
+ {
+ public String isValid( String newName )
+ {
+ if ( connection.getName().equals( newName ) )
+ return null;
+ else if ( BrowserCorePlugin.getDefault().getConnectionManager().getConnection( newName ) != null )
+ return "A connection with this name already exists.";
+ else
+ return null;
+ }
+ };
+
+ InputDialog dialog = new InputDialog( getShell(), "Rename Connection", "New name:", connection.getName(),
+ validator );
+
+ dialog.open();
+ String newName = dialog.getValue();
+ if ( newName != null )
+ {
+ connection.setName( newName );
+ }
+ }
+
+
+ protected IEntry[] getEntries()
+ {
+
+ IEntry entry = null;
+
+ if ( getSelectedEntries().length == 1 )
+ {
+ entry = getSelectedEntries()[0];
+ }
+ else if ( getSelectedSearchResults().length == 1 )
+ {
+ entry = getSelectedSearchResults()[0].getEntry();
+ }
+ else if ( getSelectedValues().length == 1 && getSelectedValues()[0].isRdnPart() )
+ {
+ entry = getSelectedValues()[0].getAttribute().getEntry();
+ }
+
+ if ( entry != null && !( entry instanceof RootDSE ) && !( entry instanceof DirectoryMetadataEntry )
+ && !( entry instanceof BaseDNEntry ) )
+ {
+ return new IEntry[]
+ { entry };
+ }
+ else
+ {
+ return new IEntry[0];
+ }
+ }
+
+
+ protected void renameEntry( final IEntry entry )
+ {
+ RenameEntryDialog renameDialog = new RenameEntryDialog( getShell(), entry );
+ if ( renameDialog.open() == Dialog.OK )
+ {
+ RDN newRdn = renameDialog.getRdn();
+ boolean deleteOldRdn = renameDialog.isDeleteOldRdn();
+ if ( newRdn != null && !newRdn.equals( entry.getRdn() ) )
+ {
+ new RenameEntryJob( entry, newRdn, deleteOldRdn ).execute();
+ }
+ }
+ }
+
+
+ protected ISearch[] getSearches()
+ {
+ if ( getSelectedSearches().length == 1 )
+ {
+ return getSelectedSearches();
+ }
+ else
+ {
+ return new ISearch[0];
+ }
+ }
+
+
+ protected void renameSearch( final ISearch search )
+ {
+ IInputValidator validator = new IInputValidator()
+ {
+ public String isValid( String newName )
+ {
+ if ( search.getName().equals( newName ) )
+ return null;
+ else if ( search.getConnection().getSearchManager().getSearch( newName ) != null )
+ return "A connection with this name already exists.";
+ else
+ return null;
+ }
+ };
+
+ InputDialog dialog = new InputDialog( getShell(), "Rename Search", "New name:", search.getName(), validator );
+
+ dialog.open();
+ String newName = dialog.getValue();
+ if ( newName != null )
+ {
+ search.setName( newName );
+ }
+ }
+
+
+ protected IBookmark[] getBookmarks()
+ {
+ if ( getSelectedBookmarks().length == 1 )
+ {
+ return getSelectedBookmarks();
+ }
+ else
+ {
+ return new IBookmark[0];
+ }
+ }
+
+
+ protected void renameBookmark( final IBookmark bookmark )
+ {
+ IInputValidator validator = new IInputValidator()
+ {
+ public String isValid( String newName )
+ {
+ if ( bookmark.getName().equals( newName ) )
+ return null;
+ else if ( bookmark.getConnection().getBookmarkManager().getBookmark( newName ) != null )
+ return "A bookmark with this name already exists.";
+ else
+ return null;
+ }
+ };
+
+ InputDialog dialog = new InputDialog( getShell(), "Rename Bookmark", "New name:", bookmark.getName(), validator );
+
+ dialog.open();
+ String newName = dialog.getValue();
+ if ( newName != null )
+ {
+ bookmark.setName( newName );
+ }
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/SelectAllAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/SelectAllAction.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/SelectAllAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/SelectAllAction.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,105 @@
+/*
+ * 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.actions;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.ConnectionManager;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
+
+
+public class SelectAllAction extends BrowserAction
+{
+
+ private Viewer viewer;
+
+
+ public SelectAllAction( Viewer viewer )
+ {
+ this.viewer = viewer;
+ }
+
+
+ public String getText()
+ {
+ return "Select All";
+ }
+
+
+ public ImageDescriptor getImageDescriptor()
+ {
+ return null;
+ }
+
+
+ public String getCommandId()
+ {
+ return IWorkbenchActionDefinitionIds.SELECT_ALL;
+ }
+
+
+ public boolean isEnabled()
+ {
+ return true;
+ }
+
+
+ public void run()
+ {
+ if ( getInput() != null && getInput() instanceof IEntry )
+ {
+ List selectionList = new ArrayList();
+ IAttribute[] attributes = ( ( IEntry ) getInput() ).getAttributes();
+ if ( attributes != null )
+ {
+ selectionList.addAll( Arrays.asList( attributes ) );
+ for ( int i = 0; i < attributes.length; i++ )
+ {
+ selectionList.addAll( Arrays.asList( attributes[i].getValues() ) );
+ }
+ }
+ StructuredSelection selection = new StructuredSelection( selectionList );
+ this.viewer.setSelection( selection );
+ }
+ else if ( getInput() != null && getInput() instanceof ConnectionManager )
+ {
+ StructuredSelection selection = new StructuredSelection( ( ( ConnectionManager ) getInput() )
+ .getConnections() );
+ this.viewer.setSelection( selection );
+ }
+ else if ( getSelectedConnections().length > 0 && viewer.getInput() instanceof ConnectionManager )
+ {
+ StructuredSelection selection = new StructuredSelection( ( ( ConnectionManager ) viewer.getInput() )
+ .getConnections() );
+ this.viewer.setSelection( selection );
+ }
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/SelectionUtils.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/SelectionUtils.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/SelectionUtils.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/SelectionUtils.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,325 @@
+/*
+ * 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.actions;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.directory.ldapstudio.browser.core.internal.model.Search;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IBookmark;
+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.ISearch;
+import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.schema.AttributeTypeDescription;
+import org.apache.directory.ldapstudio.browser.core.utils.LdapFilterUtils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.browser.BrowserCategory;
+import org.apache.directory.ldapstudio.browser.ui.widgets.browser.BrowserEntryPage;
+import org.apache.directory.ldapstudio.browser.ui.widgets.browser.BrowserSearchResultPage;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+
+public abstract class SelectionUtils
+{
+
+ public static ISearch getExampleSearch( ISelection selection )
+ {
+
+ ISearch exampleSearch = new Search();
+ String oldName = exampleSearch.getSearchParameter().getName();
+ exampleSearch.getSearchParameter().setName( null );
+ exampleSearch.setScope( ISearch.SCOPE_SUBTREE );
+
+ if ( selection != null && !selection.isEmpty() && selection instanceof StructuredSelection )
+ {
+
+ Object[] objects = ( ( IStructuredSelection ) selection ).toArray();
+ Comparator comparator = new Comparator()
+ {
+ public int compare( Object o1, Object o2 )
+ {
+ if ( ( o1 instanceof IValue ) && !( o2 instanceof IValue ) )
+ {
+ return -1;
+ }
+ else if ( !( o1 instanceof IValue ) && ( o2 instanceof IValue ) )
+ {
+ return 1;
+ }
+ else if ( ( o1 instanceof IAttribute ) && !( o2 instanceof IAttribute ) )
+ {
+ return -1;
+ }
+ else if ( !( o1 instanceof IAttribute ) && ( o2 instanceof IAttribute ) )
+ {
+ return 1;
+ }
+ else if ( ( o1 instanceof AttributeHierachie ) && !( o2 instanceof AttributeHierachie ) )
+ {
+ return -1;
+ }
+ else if ( !( o1 instanceof AttributeHierachie ) && ( o2 instanceof AttributeHierachie ) )
+ {
+ return 1;
+ }
+ return 0;
+ }
+ };
+ Arrays.sort( objects, comparator );
+ Object obj = objects[0];
+
+ if ( obj instanceof ISearch )
+ {
+ ISearch search = ( ISearch ) obj;
+ exampleSearch = ( ISearch ) search.clone();
+ exampleSearch.setName( null );
+ }
+ else if ( obj instanceof IEntry )
+ {
+ IEntry entry = ( IEntry ) obj;
+ exampleSearch.setConnection( entry.getConnection() );
+ exampleSearch.setSearchBase( entry.getDn() );
+ }
+ else if ( obj instanceof ISearchResult )
+ {
+ ISearchResult searchResult = ( ISearchResult ) obj;
+ exampleSearch.setConnection( searchResult.getEntry().getConnection() );
+ exampleSearch.setSearchBase( searchResult.getEntry().getDn() );
+ }
+ else if ( obj instanceof IBookmark )
+ {
+ IBookmark bookmark = ( IBookmark ) obj;
+ exampleSearch.setConnection( bookmark.getConnection() );
+ exampleSearch.setSearchBase( bookmark.getDn() );
+ }
+
+ else if ( obj instanceof AttributeHierachie || obj instanceof IAttribute || obj instanceof IValue )
+ {
+
+ IEntry entry = null;
+ Set filterSet = new LinkedHashSet();
+ for ( int i = 0; i < objects.length; i++ )
+ {
+ Object object = objects[i];
+ if ( object instanceof AttributeHierachie )
+ {
+ AttributeHierachie ah = ( AttributeHierachie ) object;
+ for ( Iterator it = ah.iterator(); it.hasNext(); )
+ {
+ IAttribute attribute = ( IAttribute ) it.next();
+ entry = attribute.getEntry();
+ IValue[] values = attribute.getValues();
+ for ( int v = 0; v < values.length; v++ )
+ {
+ filterSet.add( LdapFilterUtils.getFilter( values[v] ) );
+ }
+ }
+ }
+ else if ( object instanceof IAttribute )
+ {
+ IAttribute attribute = ( IAttribute ) object;
+ entry = attribute.getEntry();
+ IValue[] values = attribute.getValues();
+ for ( int v = 0; v < values.length; v++ )
+ {
+ filterSet.add( LdapFilterUtils.getFilter( values[v] ) );
+ }
+ }
+ else if ( object instanceof IValue )
+ {
+ IValue value = ( IValue ) object;
+ entry = value.getAttribute().getEntry();
+ filterSet.add( LdapFilterUtils.getFilter( value ) );
+ }
+ }
+
+ exampleSearch.setConnection( entry.getConnection() );
+ exampleSearch.setSearchBase( entry.getDn() );
+ StringBuffer filter = new StringBuffer();
+ if ( filterSet.size() > 1 )
+ {
+ filter.append( "(&" );
+ for ( Iterator filterIterator = filterSet.iterator(); filterIterator.hasNext(); )
+ {
+ filter.append( filterIterator.next() );
+ }
+ filter.append( ")" );
+ }
+ else if ( filterSet.size() == 1 )
+ {
+ filter.append( filterSet.toArray()[0] );
+ }
+ else
+ {
+ filter.append( ISearch.FILTER_TRUE );
+ }
+ exampleSearch.setFilter( filter.toString() );
+ }
+
+ else if ( obj instanceof IConnection )
+ {
+ IConnection connection = ( IConnection ) obj;
+ exampleSearch.setConnection( connection );
+ if ( connection.getBaseDNEntries().length > 0 )
+ {
+ exampleSearch.setSearchBase( connection.getBaseDNEntries()[0].getDn() );
+ }
+ }
+ else if ( obj instanceof BrowserCategory )
+ {
+ BrowserCategory cat = ( BrowserCategory ) obj;
+ exampleSearch.setConnection( cat.getParent() );
+ if ( cat.getParent().getBaseDNEntries().length > 0 )
+ {
+ exampleSearch.setSearchBase( cat.getParent().getBaseDNEntries()[0].getDn() );
+ }
+ }
+
+ }
+
+ exampleSearch.getSearchParameter().setName( oldName );
+ return exampleSearch;
+ }
+
+
+ public static BrowserCategory[] getBrowserViewCategories( ISelection selection )
+ {
+ List list = getTypes( selection, BrowserCategory.class );
+ return ( BrowserCategory[] ) list.toArray( new BrowserCategory[list.size()] );
+ }
+
+
+ public static IValue[] getValues( ISelection selection )
+ {
+ List list = getTypes( selection, IValue.class );
+ return ( IValue[] ) list.toArray( new IValue[list.size()] );
+ }
+
+
+ public static IAttribute[] getAttributes( ISelection selection )
+ {
+ List list = getTypes( selection, IAttribute.class );
+ return ( IAttribute[] ) list.toArray( new IAttribute[list.size()] );
+ }
+
+
+ public static AttributeHierachie[] getAttributeHierarchie( ISelection selection )
+ {
+ List list = getTypes( selection, AttributeHierachie.class );
+ return ( AttributeHierachie[] ) list.toArray( new AttributeHierachie[list.size()] );
+ }
+
+
+ public static String[] getProperties( ISelection selection )
+ {
+ List list = getTypes( selection, String.class );
+ return ( String[] ) list.toArray( new String[list.size()] );
+ }
+
+
+ public static AttributeTypeDescription[] getAttributeTypeDescription( ISelection selection )
+ {
+ List list = getTypes( selection, AttributeTypeDescription.class );
+ return ( AttributeTypeDescription[] ) list.toArray( new AttributeTypeDescription[list.size()] );
+ }
+
+
+ public static IEntry[] getEntries( ISelection selection )
+ {
+ List list = getTypes( selection, IEntry.class );
+ return ( IEntry[] ) list.toArray( new IEntry[list.size()] );
+ }
+
+
+ public static IBookmark[] getBookmarks( ISelection selection )
+ {
+ List list = getTypes( selection, IBookmark.class );
+ return ( IBookmark[] ) list.toArray( new IBookmark[list.size()] );
+ }
+
+
+ public static ISearchResult[] getSearchResults( ISelection selection )
+ {
+ List list = getTypes( selection, ISearchResult.class );
+ return ( ISearchResult[] ) list.toArray( new ISearchResult[list.size()] );
+ }
+
+
+ private static List getTypes( ISelection selection, Class type )
+ {
+ List list = new ArrayList();
+ if ( selection instanceof IStructuredSelection )
+ {
+ IStructuredSelection structuredSelection = ( IStructuredSelection ) selection;
+ Iterator it = structuredSelection.iterator();
+ while ( it.hasNext() )
+ {
+ Object o = it.next();
+ if ( type.isInstance( o ) )
+ {
+ list.add( o );
+ }
+ }
+ }
+ return list;
+ }
+
+
+ public static ISearch[] getSearches( ISelection selection )
+ {
+ List list = getTypes( selection, ISearch.class );
+ return ( ISearch[] ) list.toArray( new ISearch[list.size()] );
+ }
+
+
+ public static IConnection[] getConnections( ISelection selection )
+ {
+ List list = getTypes( selection, IConnection.class );
+ return ( IConnection[] ) list.toArray( new IConnection[list.size()] );
+ }
+
+
+ public static BrowserEntryPage[] getBrowserEntryPages( ISelection selection )
+ {
+ List list = getTypes( selection, BrowserEntryPage.class );
+ return ( BrowserEntryPage[] ) list.toArray( new BrowserEntryPage[list.size()] );
+ }
+
+
+ public static BrowserSearchResultPage[] getBrowserSearchResultPages( ISelection selection )
+ {
+ List list = getTypes( selection, BrowserSearchResultPage.class );
+ return ( BrowserSearchResultPage[] ) list.toArray( new BrowserSearchResultPage[list.size()] );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/ShowRawValuesAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/ShowRawValuesAction.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/ShowRawValuesAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/ShowRawValuesAction.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,66 @@
+/*
+ * 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.actions;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.eclipse.jface.action.Action;
+
+
+public class ShowRawValuesAction extends Action
+{
+
+ public ShowRawValuesAction()
+ {
+ super( "Show Raw Values", AS_CHECK_BOX );
+ super.setToolTipText( getText() );
+ super.setEnabled( true );
+
+ super.setChecked( BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_SHOW_RAW_VALUES ) );
+ }
+
+
+ public void run()
+ {
+ BrowserUIPlugin.getDefault().getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_SHOW_RAW_VALUES,
+ super.isChecked() );
+ }
+
+
+ public void setChecked( boolean checked )
+ {
+ super.setChecked( checked );
+ }
+
+
+ public boolean isChecked()
+ {
+ return super.isChecked();
+ }
+
+
+ public void dispose()
+ {
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/UnfilterSubtreeAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/UnfilterSubtreeAction.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/UnfilterSubtreeAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/UnfilterSubtreeAction.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,76 @@
+/*
+ * 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.actions;
+
+
+import org.apache.directory.ldapstudio.browser.core.jobs.InitializeChildrenJob;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+public class UnfilterSubtreeAction extends BrowserAction
+{
+
+ public UnfilterSubtreeAction()
+ {
+ super();
+ }
+
+
+ public void run()
+ {
+ if ( getSelectedEntries().length == 1 )
+ {
+ getSelectedEntries()[0].setChildrenFilter( null );
+ new InitializeChildrenJob( new IEntry[]
+ { getSelectedEntries()[0] } ).execute();
+ }
+ }
+
+
+ public String getText()
+ {
+ return "Remove Subtree Filter";
+ }
+
+
+ public ImageDescriptor getImageDescriptor()
+ {
+ return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_UNFILTER_DIT );
+ }
+
+
+ public String getCommandId()
+ {
+ return null;
+ }
+
+
+ public boolean isEnabled()
+ {
+ return getSelectedSearches().length + getSelectedSearchResults().length + getSelectedBookmarks().length == 0
+ && getSelectedEntries().length == 1 && getSelectedEntries()[0].getChildrenFilter() != null;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/UpAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/UpAction.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/UpAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/UpAction.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,131 @@
+/*
+ * 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.actions;
+
+
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.model.IBookmark;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.browser.BrowserEntryPage;
+import org.apache.directory.ldapstudio.browser.ui.widgets.browser.BrowserSearchResultPage;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+
+
+public class UpAction extends BrowserAction implements ModelModifier
+{
+
+ protected TreeViewer viewer;
+
+
+ public UpAction( TreeViewer viewer )
+ {
+ super();
+ this.viewer = viewer;
+ }
+
+
+ public String getText()
+ {
+ return "Up";
+ }
+
+
+ public ImageDescriptor getImageDescriptor()
+ {
+ return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_PARENT );
+ }
+
+
+ public String getCommandId()
+ {
+ return "org.apache.directory.ldapstudio.browser.action.openSearchResult";
+ }
+
+
+ public void run()
+ {
+ IEntry[] entries = getSelectedEntries();
+ ISearch[] searches = getSelectedSearches();
+ ISearchResult[] searchResults = getSelectedSearchResults();
+ IBookmark[] bookmarks = getSelectedBookmarks();
+ BrowserEntryPage[] browserEntryPages = getSelectedBrowserEntryPages();
+ BrowserSearchResultPage[] browserSearchResultPages = getSelectedBrowserSearchResultPages();
+
+ Object selection = null;
+
+ if ( entries.length > 0 )
+ {
+ selection = entries[0];
+ }
+ else if ( searches.length > 0 )
+ {
+ selection = searches[0];
+ }
+ else if ( searchResults.length > 0 )
+ {
+ selection = searchResults[0];
+ }
+ else if ( bookmarks.length > 0 )
+ {
+ selection = bookmarks[0];
+ }
+ else if ( browserEntryPages.length > 0 )
+ {
+ selection = browserEntryPages[0];
+ }
+ else if ( browserSearchResultPages.length > 0 )
+ {
+ selection = browserSearchResultPages[0];
+ }
+
+ if ( selection != null )
+ {
+ ITreeContentProvider contentProvider = ( ITreeContentProvider ) viewer.getContentProvider();
+ Object newSelection = contentProvider.getParent( selection );
+ viewer.reveal( newSelection );
+ viewer.setSelection( new StructuredSelection( newSelection ), true );
+ }
+
+ }
+
+
+ public boolean isEnabled()
+ {
+ IEntry[] entries = getSelectedEntries();
+ ISearch[] searches = getSelectedSearches();
+ ISearchResult[] searchResults = getSelectedSearchResults();
+ IBookmark[] bookmarks = getSelectedBookmarks();
+ BrowserEntryPage[] browserEntryPages = getSelectedBrowserEntryPages();
+ BrowserSearchResultPage[] browserSearchResultPages = getSelectedBrowserSearchResultPages();
+
+ return entries.length > 0 || searches.length > 0 || searchResults.length > 0 || bookmarks.length > 0
+ || browserEntryPages.length > 0 || browserSearchResultPages.length > 0;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/ValueEditorPreferencesAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/ValueEditorPreferencesAction.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/ValueEditorPreferencesAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/ValueEditorPreferencesAction.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,55 @@
+/*
+ * 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.actions;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.eclipse.jface.action.Action;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+
+public class ValueEditorPreferencesAction extends Action
+{
+
+ public ValueEditorPreferencesAction()
+ {
+ super.setText( "Preferences..." );
+ super.setToolTipText( "Preferences..." );
+ super.setEnabled( true );
+ }
+
+
+ public void run()
+ {
+ Shell shell = Display.getCurrent().getActiveShell();
+ String pageId = BrowserUIConstants.PREFERENCEPAGEID_VALUEEDITORS;
+ PreferencesUtil.createPreferenceDialogOn( shell, pageId, new String[]
+ { pageId }, null ).open();
+ }
+
+
+ public void dispose()
+ {
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/BrowserActionProxy.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/BrowserActionProxy.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/BrowserActionProxy.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/BrowserActionProxy.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,202 @@
+/*
+ * 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.actions.proxy;
+
+
+import org.apache.directory.ldapstudio.browser.core.events.BookmarkUpdateEvent;
+import org.apache.directory.ldapstudio.browser.core.events.BookmarkUpdateListener;
+import org.apache.directory.ldapstudio.browser.core.events.ConnectionUpdateEvent;
+import org.apache.directory.ldapstudio.browser.core.events.ConnectionUpdateListener;
+import org.apache.directory.ldapstudio.browser.core.events.EntryModificationEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EntryUpdateListener;
+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.events.SearchUpdateListener;
+import org.apache.directory.ldapstudio.browser.ui.actions.BrowserAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.SelectionUtils;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+
+public abstract class BrowserActionProxy extends Action implements ISelectionChangedListener, EntryUpdateListener,
+ SearchUpdateListener, BookmarkUpdateListener, ConnectionUpdateListener
+{
+
+ protected BrowserAction action;
+
+ protected ISelectionProvider selectionProvider;
+
+
+ protected BrowserActionProxy( ISelectionProvider selectionProvider, BrowserAction action, int style )
+ {
+ super( action.getText(), style );
+ this.selectionProvider = selectionProvider;
+ this.action = action;
+
+ super.setImageDescriptor( action.getImageDescriptor() );
+ super.setActionDefinitionId( action.getCommandId() );
+
+ this.selectionProvider.addSelectionChangedListener( this );
+ // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addSelectionListener(this);
+
+ EventRegistry.addConnectionUpdateListener( this );
+ EventRegistry.addEntryUpdateListener( this );
+ EventRegistry.addSearchUpdateListener( this );
+ EventRegistry.addBookmarkUpdateListener( this );
+
+ this.updateAction();
+
+ }
+
+
+ protected BrowserActionProxy( ISelectionProvider selectionProvider, BrowserAction action )
+ {
+ this( selectionProvider, action, Action.AS_PUSH_BUTTON );
+ }
+
+
+ public void dispose()
+ {
+ EventRegistry.removeConnectionUpdateListener( this );
+ EventRegistry.removeEntryUpdateListener( this );
+ EventRegistry.removeSearchUpdateListener( this );
+ EventRegistry.removeBookmarkUpdateListener( this );
+ this.selectionProvider.removeSelectionChangedListener( this );
+ // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().removeSelectionListener(this);
+
+ this.action.dispose();
+ this.action = null;
+ }
+
+
+ public boolean isDisposed()
+ {
+ return this.action == null;
+ }
+
+
+ public final void entryUpdated( EntryModificationEvent entryModificationEvent )
+ {
+ if ( !this.isDisposed() )
+ {
+ this.action.entryUpdated( entryModificationEvent );
+ this.updateAction();
+ }
+ }
+
+
+ public void searchUpdated( SearchUpdateEvent searchUpdateEvent )
+ {
+ if ( !this.isDisposed() )
+ {
+ this.action.searchUpdated( searchUpdateEvent );
+ this.updateAction();
+ }
+ }
+
+
+ public void bookmarkUpdated( BookmarkUpdateEvent bookmarkUpdateEvent )
+ {
+ if ( !this.isDisposed() )
+ {
+ this.action.bookmarkUpdated( bookmarkUpdateEvent );
+ this.updateAction();
+ }
+ }
+
+
+ public final void connectionUpdated( ConnectionUpdateEvent connectionUpdateEvent )
+ {
+ if ( !this.isDisposed() )
+ {
+ this.action.connectionUpdated( connectionUpdateEvent );
+ this.updateAction();
+ }
+ }
+
+
+ public void inputChanged( Object input )
+ {
+ if ( !this.isDisposed() )
+ {
+ this.action.setInput( input );
+ this.selectionChanged( new SelectionChangedEvent( this.selectionProvider, new StructuredSelection() ) );
+ // this.updateAction();
+ }
+ }
+
+
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ if ( !this.isDisposed() )
+ {
+ ISelection selection = event.getSelection();
+
+ this.action.setSelectedConnections( SelectionUtils.getConnections( selection ) );
+
+ this.action.setSelectedBrowserViewCategories( SelectionUtils.getBrowserViewCategories( selection ) );
+ this.action.setSelectedEntries( SelectionUtils.getEntries( selection ) );
+ this.action.setSelectedBrowserEntryPages( SelectionUtils.getBrowserEntryPages( selection ) );
+ this.action.setSelectedSearchResults( SelectionUtils.getSearchResults( selection ) );
+ this.action.setSelectedBrowserSearchResultPages( SelectionUtils.getBrowserSearchResultPages( selection ) );
+ this.action.setSelectedBookmarks( SelectionUtils.getBookmarks( selection ) );
+
+ this.action.setSelectedSearches( SelectionUtils.getSearches( selection ) );
+
+ this.action.setSelectedAttributes( SelectionUtils.getAttributes( selection ) );
+ this.action.setSelectedAttributeHierarchies( SelectionUtils.getAttributeHierarchie( selection ) );
+ this.action.setSelectedValues( SelectionUtils.getValues( selection ) );
+ this.updateAction();
+ }
+ }
+
+
+ public void updateAction()
+ {
+ if ( !this.isDisposed() )
+ {
+ this.setText( this.action.getText() );
+ this.setToolTipText( this.action.getText() );
+ this.setEnabled( this.action.isEnabled() );
+ }
+ }
+
+
+ public void run()
+ {
+ if ( !this.isDisposed() )
+ {
+ this.action.run();
+ }
+ }
+
+
+ public BrowserAction getAction()
+ {
+ return action;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/BrowserViewActionProxy.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/BrowserViewActionProxy.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/BrowserViewActionProxy.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/BrowserViewActionProxy.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,42 @@
+/*
+ * 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.actions.proxy;
+
+
+import org.apache.directory.ldapstudio.browser.ui.actions.BrowserAction;
+import org.eclipse.jface.viewers.Viewer;
+
+
+public class BrowserViewActionProxy extends BrowserActionProxy
+{
+
+ public BrowserViewActionProxy( Viewer viewer, BrowserAction action, int style )
+ {
+ super( viewer, action, style );
+ }
+
+
+ public BrowserViewActionProxy( Viewer viewer, BrowserAction action )
+ {
+ super( viewer, action );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/ConnectionViewActionProxy.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/ConnectionViewActionProxy.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/ConnectionViewActionProxy.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/ConnectionViewActionProxy.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,42 @@
+/*
+ * 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.actions.proxy;
+
+
+import org.apache.directory.ldapstudio.browser.ui.actions.BrowserAction;
+import org.eclipse.jface.viewers.Viewer;
+
+
+public class ConnectionViewActionProxy extends BrowserActionProxy
+{
+
+ public ConnectionViewActionProxy( Viewer viewer, BrowserAction action, int style )
+ {
+ super( viewer, action, style );
+ }
+
+
+ public ConnectionViewActionProxy( Viewer viewer, BrowserAction action )
+ {
+ super( viewer, action );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/EntryEditorActionProxy.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/EntryEditorActionProxy.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/EntryEditorActionProxy.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/EntryEditorActionProxy.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,43 @@
+/*
+ * 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.actions.proxy;
+
+
+import org.apache.directory.ldapstudio.browser.ui.actions.BrowserAction;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.Viewer;
+
+
+public class EntryEditorActionProxy extends BrowserActionProxy implements ISelectionChangedListener
+{
+
+ public EntryEditorActionProxy( Viewer viewer, BrowserAction action, int style )
+ {
+ super( viewer, action, style );
+ }
+
+
+ public EntryEditorActionProxy( Viewer viewer, BrowserAction action )
+ {
+ super( viewer, action );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/ModificationLogsViewActionProxy.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/ModificationLogsViewActionProxy.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/ModificationLogsViewActionProxy.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/ModificationLogsViewActionProxy.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,42 @@
+/*
+ * 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.actions.proxy;
+
+
+import org.apache.directory.ldapstudio.browser.ui.actions.BrowserAction;
+import org.eclipse.jface.viewers.Viewer;
+
+
+public class ModificationLogsViewActionProxy extends BrowserActionProxy
+{
+
+ public ModificationLogsViewActionProxy( Viewer viewer, BrowserAction action, int style )
+ {
+ super( viewer, action, style );
+ }
+
+
+ public ModificationLogsViewActionProxy( Viewer viewer, BrowserAction action )
+ {
+ super( viewer, action );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/SearchResultEditorActionProxy.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/SearchResultEditorActionProxy.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/SearchResultEditorActionProxy.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/actions/proxy/SearchResultEditorActionProxy.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,42 @@
+/*
+ * 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.actions.proxy;
+
+
+import org.apache.directory.ldapstudio.browser.ui.actions.BrowserAction;
+import org.apache.directory.ldapstudio.browser.ui.editors.searchresult.SearchResultEditorCursor;
+
+
+public class SearchResultEditorActionProxy extends BrowserActionProxy
+{
+
+ public SearchResultEditorActionProxy( SearchResultEditorCursor cursor, BrowserAction action, int style )
+ {
+ super( cursor, action, style );
+ }
+
+
+ public SearchResultEditorActionProxy( SearchResultEditorCursor cursor, BrowserAction action )
+ {
+ super( cursor, action );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/browseruimessages.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/browseruimessages.properties?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/browseruimessages.properties (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/browseruimessages.properties Mon Dec 18 09:52:58 2006
@@ -0,0 +1,3 @@
+ldifeditor__contentassistproposal_label=Content Assist
+ldifeditor__contentassistproposal_tooltip=Content Assist
+ldifeditor__contentassistproposal_description=Content Assist
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/AddressDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/AddressDialog.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/AddressDialog.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/AddressDialog.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,121 @@
+/*
+ * 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;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+
+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;
+
+
+public class AddressDialog extends Dialog
+{
+
+ public static final String DIALOG_TITLE = "Address Editor";
+
+ public static final double MAX_WIDTH = 250.0;
+
+ public static final double MAX_HEIGHT = 250.0;
+
+ private String initialValue;
+
+ private String returnValue;
+
+ private Text text;
+
+
+ public AddressDialog( Shell parentShell, String initialValue )
+ {
+ super( parentShell );
+ super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+ this.initialValue = initialValue;
+ this.returnValue = null;
+ }
+
+
+ public boolean close()
+ {
+ return super.close();
+ }
+
+
+ protected void configureShell( Shell shell )
+ {
+ super.configureShell( shell );
+ shell.setText( DIALOG_TITLE );
+ shell.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_ADDRESSEDITOR ) );
+ }
+
+
+ protected void createButtonsForButtonBar( Composite parent )
+ {
+ createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+ createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+ }
+
+
+ protected void okPressed()
+ {
+ this.returnValue = this.text.getText();
+ this.returnValue = this.returnValue.replaceAll( "\n", "\\$" );
+ this.returnValue = this.returnValue.replaceAll( "\r", "\\$" );
+ this.returnValue = this.returnValue.replaceAll( "\\$\\$", "\\$" );
+ super.okPressed();
+ }
+
+
+ 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.replaceAll( "\\$", BrowserCoreConstants.LINE_SEPARATOR ) );
+ // 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;
+ }
+
+
+ public String getText()
+ {
+ return this.returnValue;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/CredentialsDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/CredentialsDialog.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/CredentialsDialog.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/CredentialsDialog.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,54 @@
+/*
+ * 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;
+
+
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class CredentialsDialog extends InputDialog
+{
+
+ public CredentialsDialog( Shell parentShell, String dialogTitle, String dialogMessage, String initialValue,
+ IInputValidator validator )
+ {
+ super( parentShell, dialogTitle, dialogMessage, initialValue, validator );
+ }
+
+
+ protected void setShellStyle( int newShellStyle )
+ {
+ super.setShellStyle( newShellStyle );
+ }
+
+
+ protected Control createDialogArea( Composite parent )
+ {
+ Composite composite = ( Composite ) super.createDialogArea( parent );
+ super.getText().setEchoChar( '*' );
+ return composite;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/DnDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/DnDialog.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/DnDialog.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/DnDialog.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,118 @@
+/*
+ * 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;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+import org.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.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;
+
+
+public class DnDialog extends Dialog implements WidgetModifyListener
+{
+
+ public static final String DIALOG_TITLE = "DN Editor";
+
+ private EntryWidget entryWidget;
+
+ private IConnection connection;
+
+ private DN dn;
+
+
+ public DnDialog( Shell parentShell, IConnection connection, DN dn )
+ {
+ super( parentShell );
+ super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+ this.connection = connection;
+ this.dn = dn;
+ }
+
+
+ protected void configureShell( Shell shell )
+ {
+ super.configureShell( shell );
+ shell.setText( DIALOG_TITLE );
+ shell.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_DNEDITOR ) );
+ }
+
+
+ public boolean close()
+ {
+ this.entryWidget.removeWidgetModifyListener( this );
+ return super.close();
+ }
+
+
+ protected void okPressed()
+ {
+ this.dn = this.entryWidget.getDn();
+ this.entryWidget.saveDialogSettings();
+ super.okPressed();
+ }
+
+
+ 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 ) * 3 / 2;
+ composite.setLayoutData( gd );
+
+ Composite innerComposite = BaseWidgetUtils.createColumnContainer( composite, 2, 1 );
+ this.entryWidget = new EntryWidget( connection, dn );
+ this.entryWidget.addWidgetModifyListener( this );
+ this.entryWidget.createWidget( innerComposite );
+
+ applyDialogFont( composite );
+ return composite;
+ }
+
+
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ if ( getButton( IDialogConstants.OK_ID ) != null )
+ {
+ getButton( IDialogConstants.OK_ID ).setEnabled( this.entryWidget.getDn() != null );
+ }
+ }
+
+
+ public DN getDn()
+ {
+ return this.dn;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/EncoderDecoderDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/EncoderDecoderDialog.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/EncoderDecoderDialog.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/EncoderDecoderDialog.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,225 @@
+/*
+ * 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;
+
+
+import org.apache.directory.ldapstudio.browser.core.utils.LdifUtils;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+public class EncoderDecoderDialog extends Dialog
+{
+
+ public static final String DIALOG_TITLE = "LDAP Encoder/Decoder";
+
+ private Text iso88591Text;
+
+ private Text iso88591HexText;
+
+ private Text utf8Text;
+
+ private Text utf8HexText;
+
+ private Text base64Text;
+
+ private Text errorText;
+
+ private boolean inModify = false;
+
+
+ public EncoderDecoderDialog( Shell parentShell )
+ {
+ super( parentShell );
+ super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+ }
+
+
+ protected void configureShell( Shell shell )
+ {
+ super.configureShell( shell );
+ shell.setText( DIALOG_TITLE );
+ shell.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_IMAGEEDITOR ) );
+ }
+
+
+ protected Control createDialogArea( Composite parent )
+ {
+
+ Composite composite2 = ( Composite ) super.createDialogArea( parent );
+ GridData gd1 = new GridData( GridData.FILL_BOTH );
+ gd1.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+ gd1.heightHint = convertVerticalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+ composite2.setLayoutData( gd1 );
+
+ Composite composite = BaseWidgetUtils.createColumnContainer( composite2, 2, 1 );
+ composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+ Label iso8859Label = new Label( composite, SWT.NONE );
+ iso8859Label.setText( "ISO-8859-1:" );
+ iso88591Text = new Text( composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL );
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ iso88591Text.setLayoutData( gd );
+
+ Label iso8859HexLabel = new Label( composite, SWT.NONE );
+ iso8859HexLabel.setText( "ISO-8859-1 Hex:" );
+ iso88591HexText = new Text( composite, SWT.BORDER | SWT.READ_ONLY );
+ iso88591HexText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+ Label utf8Label = new Label( composite, SWT.NONE );
+ utf8Label.setText( "UTF-8:" );
+ utf8Text = new Text( composite, SWT.BORDER );
+ utf8Text.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+ Label utf8HexLabel = new Label( composite, SWT.NONE );
+ utf8HexLabel.setText( "UTF-8 Hex:" );
+ utf8HexText = new Text( composite, SWT.BORDER | SWT.READ_ONLY );
+ utf8HexText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+ Label base64Label = new Label( composite, SWT.NONE );
+ base64Label.setText( "BASE-64:" );
+ base64Text = new Text( composite, SWT.BORDER );
+ base64Text.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+ errorText = new Text( composite, SWT.BORDER | SWT.READ_ONLY );
+ gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.horizontalSpan = 2;
+ errorText.setLayoutData( gd );
+
+ iso88591Text.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ if ( !inModify )
+ {
+ inModify = true;
+ try
+ {
+ String iso = iso88591Text.getText();
+ byte[] isoHex = iso.getBytes( "ISO-8859-1" );
+ byte[] utf8 = LdifUtils.utf8encode( iso );
+ String utf8String = new String( utf8, "ISO-8859-1" );
+ String base64 = LdifUtils.base64encode( utf8 );
+
+ iso88591HexText.setText( LdifUtils.hexEncode( isoHex ) );
+ utf8Text.setText( utf8String );
+ utf8HexText.setText( LdifUtils.hexEncode( utf8 ) );
+ base64Text.setText( base64 );
+ errorText.setText( "" );
+ }
+ catch ( Exception ex )
+ {
+ errorText.setText( ex.getMessage() );
+ ex.printStackTrace();
+ }
+ finally
+ {
+ inModify = false;
+ }
+ }
+ }
+ } );
+
+ utf8Text.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ if ( !inModify )
+ {
+ inModify = true;
+ try
+ {
+ String utf8String = utf8Text.getText();
+ byte[] utf8 = utf8String.getBytes( "ISO-8859-1" );
+ String iso = LdifUtils.utf8decode( utf8 );
+ byte[] isoHex = iso.getBytes( "ISO-8859-1" );
+ String base64 = LdifUtils.base64encode( utf8 );
+
+ iso88591Text.setText( iso );
+ iso88591HexText.setText( LdifUtils.hexEncode( isoHex ) );
+ utf8HexText.setText( LdifUtils.hexEncode( utf8 ) );
+ base64Text.setText( base64 );
+ errorText.setText( "" );
+ }
+ catch ( Exception ex )
+ {
+ errorText.setText( ex.getMessage() );
+ ex.printStackTrace();
+ }
+ finally
+ {
+ inModify = false;
+ }
+ }
+ }
+ } );
+
+ base64Text.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ if ( !inModify )
+ {
+ inModify = true;
+ try
+ {
+ String base64 = base64Text.getText();
+ byte[] utf8 = LdifUtils.base64decodeToByteArray( base64 );
+ String utf8String = new String( utf8, "ISO-8859-1" );
+ String iso = LdifUtils.utf8decode( utf8 );
+ byte[] isoHex = iso.getBytes( "ISO-8859-1" );
+
+ iso88591Text.setText( iso );
+ iso88591HexText.setText( LdifUtils.hexEncode( isoHex ) );
+ utf8Text.setText( utf8String );
+ utf8HexText.setText( LdifUtils.hexEncode( utf8 ) );
+ errorText.setText( "" );
+ }
+ catch ( Exception ex )
+ {
+ errorText.setText( ex.getMessage() );
+ ex.printStackTrace();
+ }
+ finally
+ {
+ inModify = false;
+ }
+ }
+ }
+ } );
+
+ return composite;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterDialog.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterDialog.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterDialog.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,147 @@
+/*
+ * 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;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.filter.parser.LdapFilterParser;
+import org.apache.directory.ldapstudio.browser.ui.editors.filter.FilterSourceViewerConfiguration;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.source.VerticalRuler;
+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;
+
+
+public class FilterDialog extends Dialog
+{
+
+ public static final String DIALOG_TITLE = "Filter Editor";
+
+ private String title;
+
+ private IConnection connection;
+
+ private SourceViewer sourceViewer;
+
+ private FilterSourceViewerConfiguration configuration;
+
+ private LdapFilterParser parser;
+
+ private String filter;
+
+
+ public FilterDialog( Shell parentShell, String title, String filter, IConnection connection )
+ {
+ super( parentShell );
+ this.title = title;
+ this.filter = filter;
+ this.connection = connection;
+ this.parser = new LdapFilterParser();
+ setShellStyle( SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE );
+ }
+
+
+ public String getFilter()
+ {
+ return this.filter;
+ }
+
+
+ protected void configureShell( Shell newShell )
+ {
+ super.configureShell( newShell );
+ newShell.setText( this.title != null ? this.title : DIALOG_TITLE );
+ }
+
+
+ protected void buttonPressed( int buttonId )
+ {
+ if ( buttonId == IDialogConstants.OK_ID )
+ {
+ // this.filter = sourceViewer.getDocument().get();
+ this.parser.parse( sourceViewer.getDocument().get() );
+ this.filter = this.parser.getModel().toString();
+ }
+ else if ( buttonId == 987654321 )
+ {
+ IRegion region = new Region( 0, sourceViewer.getDocument().getLength() );
+ configuration.getContentFormatter( sourceViewer ).format( sourceViewer.getDocument(), region );
+ }
+
+ // call super implementation
+ super.buttonPressed( buttonId );
+ }
+
+
+ protected Control createButtonBar( Composite parent )
+ {
+ Composite composite = ( Composite ) super.createButtonBar( parent );
+ super.createButton( composite, 987654321, "Format", false );
+ return composite;
+ }
+
+
+ protected Control createDialogArea( Composite parent )
+ {
+ // Composite 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 and configure source viewer
+ sourceViewer = new SourceViewer( composite, new VerticalRuler( 0 ), SWT.H_SCROLL | SWT.V_SCROLL );
+ sourceViewer.getControl().setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ configuration = new FilterSourceViewerConfiguration( this.sourceViewer, this.parser, this.connection );
+ sourceViewer.configure( configuration );
+
+ // set document
+ IDocument document = new Document( this.filter );
+ sourceViewer.setDocument( document );
+
+ // preformat
+ IRegion region = new Region( 0, sourceViewer.getDocument().getLength() );
+ configuration.getContentFormatter( sourceViewer ).format( sourceViewer.getDocument(), region );
+
+ sourceViewer.getTextWidget().setFocus();
+
+ return composite;
+ }
+
+
+ protected boolean canHandleShellCloseEvent()
+ {
+ // proposal popup is opened, don't close dialog!
+ return super.canHandleShellCloseEvent();
+ }
+
+}