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 [13/23] - in /directory/sandbox/pamarcelot/ldapstudio:
ldapstudio-browser-ui/ ldapstudio-browser-ui/META-INF/
ldapstudio-browser-ui/about_files/ ldapstudio-browser-ui/icons/
ldapstudio-browser-ui/icons/ovr16/ ldapstudio-browser-ui/s...
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/ConnectionTransfer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/ConnectionTransfer.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/ConnectionTransfer.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/ConnectionTransfer.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.dnd;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+
+import org.eclipse.swt.dnd.ByteArrayTransfer;
+import org.eclipse.swt.dnd.TransferData;
+
+
+public class ConnectionTransfer extends ByteArrayTransfer
+{
+
+ private static final String TYPENAME = "org.apache.directory.ldapstudio.browser.connection";
+
+ private static final int TYPEID = registerType( TYPENAME );
+
+ private static ConnectionTransfer instance = new ConnectionTransfer();
+
+
+ private ConnectionTransfer()
+ {
+ }
+
+
+ public static ConnectionTransfer getInstance()
+ {
+ return instance;
+ }
+
+
+ public void javaToNative( Object object, TransferData transferData )
+ {
+ if ( object == null || !( object instanceof IConnection[] ) )
+ return;
+
+ if ( isSupportedType( transferData ) )
+ {
+ IConnection[] connections = ( IConnection[] ) object;
+ try
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ DataOutputStream writeOut = new DataOutputStream( out );
+
+ for ( int i = 0; i < connections.length; i++ )
+ {
+ byte[] name = connections[i].getName().getBytes();
+ writeOut.writeInt( name.length );
+ writeOut.write( name );
+ }
+
+ byte[] buffer = out.toByteArray();
+ writeOut.close();
+
+ super.javaToNative( buffer, transferData );
+
+ }
+ catch ( IOException e )
+ {
+ }
+ }
+ }
+
+
+ public Object nativeToJava( TransferData transferData )
+ {
+
+ if ( isSupportedType( transferData ) )
+ {
+
+ byte[] buffer = ( byte[] ) super.nativeToJava( transferData );
+ if ( buffer == null )
+ return null;
+
+ List connectionList = new ArrayList();
+ try
+ {
+ ByteArrayInputStream in = new ByteArrayInputStream( buffer );
+ DataInputStream readIn = new DataInputStream( in );
+
+ do
+ {
+ if ( readIn.available() > 1 )
+ {
+ int size = readIn.readInt();
+ byte[] connectionName = new byte[size];
+ readIn.read( connectionName );
+ IConnection connection = BrowserCorePlugin.getDefault().getConnectionManager().getConnection(
+ new String( connectionName ) );
+ connectionList.add( connection );
+ }
+ }
+ while ( readIn.available() > 1 );
+
+ readIn.close();
+ }
+ catch ( IOException ex )
+ {
+ return null;
+ }
+
+ return connectionList.toArray( new IConnection[0] );
+ }
+
+ return null;
+ }
+
+
+ protected String[] getTypeNames()
+ {
+ return new String[]
+ { TYPENAME };
+ }
+
+
+ protected int[] getTypeIds()
+ {
+ return new int[]
+ { TYPEID };
+ }
+
+}
\ No newline at end of file
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/EntryTransfer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/EntryTransfer.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/EntryTransfer.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/EntryTransfer.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.dnd;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+
+import org.eclipse.swt.dnd.ByteArrayTransfer;
+import org.eclipse.swt.dnd.TransferData;
+
+
+public class EntryTransfer extends ByteArrayTransfer
+{
+
+ private static final String TYPENAME = "org.apache.directory.ldapstudio.browser.entry";
+
+ private static final int TYPEID = registerType( TYPENAME );
+
+ private static EntryTransfer instance = new EntryTransfer();
+
+
+ public static EntryTransfer getInstance()
+ {
+ return instance;
+ }
+
+
+ private EntryTransfer()
+ {
+ }
+
+
+ public void javaToNative( Object object, TransferData transferData )
+ {
+ if ( object == null || !( object instanceof IEntry[] ) )
+ return;
+
+ if ( isSupportedType( transferData ) )
+ {
+ IEntry[] entries = ( IEntry[] ) object;
+ try
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ DataOutputStream writeOut = new DataOutputStream( out );
+
+ for ( int i = 0; i < entries.length; i++ )
+ {
+ byte[] connectionName = entries[i].getConnection().getName().getBytes();
+ writeOut.writeInt( connectionName.length );
+ writeOut.write( connectionName );
+ byte[] dn = entries[i].getDn().toString().getBytes();
+ writeOut.writeInt( dn.length );
+ writeOut.write( dn );
+ }
+
+ byte[] buffer = out.toByteArray();
+ writeOut.close();
+
+ super.javaToNative( buffer, transferData );
+
+ }
+ catch ( IOException e )
+ {
+ }
+ }
+ }
+
+
+ public Object nativeToJava( TransferData transferData )
+ {
+
+ try
+ {
+
+ if ( isSupportedType( transferData ) )
+ {
+
+ byte[] buffer = ( byte[] ) super.nativeToJava( transferData );
+ if ( buffer == null )
+ return null;
+
+ List entryList = new ArrayList();
+ try
+ {
+ IConnection connection = null;
+ ByteArrayInputStream in = new ByteArrayInputStream( buffer );
+ DataInputStream readIn = new DataInputStream( in );
+
+ do
+ {
+ if ( readIn.available() > 1 )
+ {
+ int size = readIn.readInt();
+ byte[] connectionName = new byte[size];
+ readIn.read( connectionName );
+ connection = BrowserCorePlugin.getDefault().getConnectionManager().getConnection(
+ new String( connectionName ) );
+ }
+
+ IEntry entry = null;
+ if ( readIn.available() > 1 && connection != null )
+ {
+ int size = readIn.readInt();
+ byte[] dn = new byte[size];
+ readIn.read( dn );
+ entry = connection.getEntryFromCache( new DN( new String( dn ) ) );
+
+ }
+ else
+ {
+ return null;
+ }
+
+ if ( entry != null )
+ {
+ entryList.add( entry );
+ }
+ }
+ while ( readIn.available() > 1 );
+
+ readIn.close();
+ }
+ catch ( IOException ex )
+ {
+ return null;
+ }
+
+ return entryList.isEmpty() ? null : entryList.toArray( new IEntry[0] );
+ }
+
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+
+ return null;
+
+ }
+
+
+ protected String[] getTypeNames()
+ {
+ return new String[]
+ { TYPENAME };
+ }
+
+
+ protected int[] getTypeIds()
+ {
+ return new int[]
+ { TYPEID };
+ }
+
+}
\ No newline at end of file
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/LdifAttrValLinesTransfer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/LdifAttrValLinesTransfer.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/LdifAttrValLinesTransfer.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/LdifAttrValLinesTransfer.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.dnd;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifFile;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifContentRecord;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifAttrValLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.parser.LdifParser;
+
+import org.eclipse.swt.dnd.ByteArrayTransfer;
+import org.eclipse.swt.dnd.TransferData;
+
+
+public class LdifAttrValLinesTransfer extends ByteArrayTransfer
+{
+
+ private static final String TYPENAME = "org.apache.directory.ldapstudio.browser.ldifAttrValLine";
+
+ private static final int TYPEID = registerType( TYPENAME );
+
+ private static LdifAttrValLinesTransfer instance = new LdifAttrValLinesTransfer();
+
+
+ private LdifAttrValLinesTransfer()
+ {
+ }
+
+
+ public static LdifAttrValLinesTransfer getInstance()
+ {
+ return instance;
+ }
+
+
+ public void javaToNative( Object object, TransferData transferData )
+ {
+ if ( object == null || !( object instanceof LdifAttrValLine[] ) )
+ return;
+
+ if ( isSupportedType( transferData ) )
+ {
+ LdifAttrValLine[] lines = ( LdifAttrValLine[] ) object;
+
+ StringBuffer sb = new StringBuffer();
+ sb.append( "dn: cn=dummy\n" );
+ for ( int i = 0; i < lines.length; i++ )
+ {
+ sb.append( lines[i].toFormattedString() );
+ }
+
+ try
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ DataOutputStream writeOut = new DataOutputStream( out );
+
+ byte[] bytes = sb.toString().getBytes();
+ writeOut.writeInt( bytes.length );
+ writeOut.write( bytes );
+
+ byte[] buffer = out.toByteArray();
+ writeOut.close();
+
+ super.javaToNative( buffer, transferData );
+
+ }
+ catch ( IOException e )
+ {
+ }
+ }
+ }
+
+
+ public Object nativeToJava( TransferData transferData )
+ {
+
+ try
+ {
+
+ if ( isSupportedType( transferData ) )
+ {
+
+ byte[] buffer = ( byte[] ) super.nativeToJava( transferData );
+ if ( buffer == null )
+ return null;
+
+ LdifAttrValLine[] lines = null;
+ try
+ {
+
+ ByteArrayInputStream in = new ByteArrayInputStream( buffer );
+ DataInputStream readIn = new DataInputStream( in );
+
+ if ( readIn.available() > 1 )
+ {
+ int size = readIn.readInt();
+ byte[] bytes = new byte[size];
+ readIn.read( bytes );
+ String ldif = new String( bytes );
+ LdifFile model = new LdifParser().parse( ldif );
+ if ( model.getRecords().length == 1 && ( model.getRecords()[0] instanceof LdifContentRecord ) )
+ {
+ lines = ( ( LdifContentRecord ) model.getRecords()[0] ).getAttrVals();
+ }
+ }
+
+ readIn.close();
+ }
+ catch ( IOException ex )
+ {
+ return null;
+ }
+
+ return lines;
+ }
+
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+
+ return null;
+
+ }
+
+
+ protected String[] getTypeNames()
+ {
+ return new String[]
+ { TYPENAME };
+ }
+
+
+ protected int[] getTypeIds()
+ {
+ return new int[]
+ { TYPEID };
+ }
+
+}
\ No newline at end of file
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/LdifContentRecordTransfer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/LdifContentRecordTransfer.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/LdifContentRecordTransfer.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/LdifContentRecordTransfer.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.dnd;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifFile;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifContentRecord;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifRecord;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.parser.LdifParser;
+
+import org.eclipse.swt.dnd.ByteArrayTransfer;
+import org.eclipse.swt.dnd.TransferData;
+
+
+public class LdifContentRecordTransfer extends ByteArrayTransfer
+{
+
+ private static final String TYPENAME = "org.apache.directory.ldapstudio.browser.ldifContentRecord";
+
+ private static final int TYPEID = registerType( TYPENAME );
+
+ private static LdifContentRecordTransfer instance = new LdifContentRecordTransfer();
+
+
+ private LdifContentRecordTransfer()
+ {
+ }
+
+
+ public static LdifContentRecordTransfer getInstance()
+ {
+ return instance;
+ }
+
+
+ public void javaToNative( Object object, TransferData transferData )
+ {
+ if ( object == null || !( object instanceof LdifContentRecord[] ) )
+ return;
+
+ if ( isSupportedType( transferData ) )
+ {
+ LdifContentRecord[] records = ( LdifContentRecord[] ) object;
+
+ StringBuffer sb = new StringBuffer();
+ for ( int i = 0; i < records.length; i++ )
+ {
+ sb.append( records[i].toFormattedString() );
+ }
+
+ try
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ DataOutputStream writeOut = new DataOutputStream( out );
+
+ byte[] bytes = sb.toString().getBytes();
+ writeOut.writeInt( bytes.length );
+ writeOut.write( bytes );
+
+ byte[] buffer = out.toByteArray();
+ writeOut.close();
+
+ super.javaToNative( buffer, transferData );
+
+ }
+ catch ( IOException e )
+ {
+ }
+ }
+ }
+
+
+ public Object nativeToJava( TransferData transferData )
+ {
+
+ try
+ {
+
+ if ( isSupportedType( transferData ) )
+ {
+
+ byte[] buffer = ( byte[] ) super.nativeToJava( transferData );
+ if ( buffer == null )
+ return null;
+
+ LdifContentRecord[] records = null;
+ try
+ {
+
+ ByteArrayInputStream in = new ByteArrayInputStream( buffer );
+ DataInputStream readIn = new DataInputStream( in );
+
+ if ( readIn.available() > 1 )
+ {
+ int size = readIn.readInt();
+ byte[] bytes = new byte[size];
+ readIn.read( bytes );
+ String ldif = new String( bytes );
+ LdifFile model = new LdifParser().parse( ldif );
+ LdifRecord[] ldifRecords = model.getRecords();
+ records = new LdifContentRecord[ldifRecords.length];
+ for ( int i = 0; i < ldifRecords.length; i++ )
+ {
+ if ( ldifRecords[i] instanceof LdifContentRecord )
+ {
+ records[i] = ( LdifContentRecord ) ldifRecords[i];
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ readIn.close();
+ }
+ catch ( IOException ex )
+ {
+ return null;
+ }
+
+ return records;
+ }
+
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+
+ return null;
+
+ }
+
+
+ protected String[] getTypeNames()
+ {
+ return new String[]
+ { TYPENAME };
+ }
+
+
+ protected int[] getTypeIds()
+ {
+ return new int[]
+ { TYPEID };
+ }
+
+}
\ No newline at end of file
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/SearchTransfer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/SearchTransfer.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/SearchTransfer.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/SearchTransfer.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.dnd;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+
+import org.eclipse.swt.dnd.ByteArrayTransfer;
+import org.eclipse.swt.dnd.TransferData;
+
+
+public class SearchTransfer extends ByteArrayTransfer
+{
+
+ private static final String TYPENAME = "org.apache.directory.ldapstudio.browser.search";
+
+ private static final int TYPEID = registerType( TYPENAME );
+
+ private static SearchTransfer instance = new SearchTransfer();
+
+
+ private SearchTransfer()
+ {
+ }
+
+
+ public static SearchTransfer getInstance()
+ {
+ return instance;
+ }
+
+
+ public void javaToNative( Object object, TransferData transferData )
+ {
+ if ( object == null || !( object instanceof ISearch[] ) )
+ return;
+
+ if ( isSupportedType( transferData ) )
+ {
+ ISearch[] searches = ( ISearch[] ) object;
+ try
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ DataOutputStream writeOut = new DataOutputStream( out );
+
+ for ( int i = 0; i < searches.length; i++ )
+ {
+ byte[] connectionName = searches[i].getConnection().getName().getBytes();
+ writeOut.writeInt( connectionName.length );
+ writeOut.write( connectionName );
+ byte[] searchName = searches[i].getName().getBytes();
+ writeOut.writeInt( searchName.length );
+ writeOut.write( searchName );
+ }
+
+ byte[] buffer = out.toByteArray();
+ writeOut.close();
+
+ super.javaToNative( buffer, transferData );
+
+ }
+ catch ( IOException e )
+ {
+ }
+ }
+ }
+
+
+ public Object nativeToJava( TransferData transferData )
+ {
+
+ try
+ {
+
+ if ( isSupportedType( transferData ) )
+ {
+
+ byte[] buffer = ( byte[] ) super.nativeToJava( transferData );
+ if ( buffer == null )
+ return null;
+
+ List searchList = new ArrayList();
+ try
+ {
+ IConnection connection = null;
+ ByteArrayInputStream in = new ByteArrayInputStream( buffer );
+ DataInputStream readIn = new DataInputStream( in );
+
+ do
+ {
+ if ( readIn.available() > 1 )
+ {
+ int size = readIn.readInt();
+ byte[] connectionName = new byte[size];
+ readIn.read( connectionName );
+ connection = BrowserCorePlugin.getDefault().getConnectionManager().getConnection(
+ new String( connectionName ) );
+ }
+
+ ISearch search = null;
+ if ( readIn.available() > 1 && connection != null )
+ {
+ int size = readIn.readInt();
+ byte[] searchName = new byte[size];
+ readIn.read( searchName );
+ search = connection.getSearchManager().getSearch( new String( searchName ) );
+ }
+ else
+ {
+ return null;
+ }
+
+ if ( search != null )
+ {
+ searchList.add( search );
+ }
+ }
+ while ( readIn.available() > 1 );
+
+ readIn.close();
+ }
+ catch ( IOException ex )
+ {
+ return null;
+ }
+
+ return searchList.isEmpty() ? null : searchList.toArray( new ISearch[0] );
+ }
+
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+
+ return null;
+
+ }
+
+
+ protected String[] getTypeNames()
+ {
+ return new String[]
+ { TYPENAME };
+ }
+
+
+ protected int[] getTypeIds()
+ {
+ return new int[]
+ { TYPEID };
+ }
+
+}
\ No newline at end of file
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/ValuesTransfer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/ValuesTransfer.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/ValuesTransfer.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/dnd/ValuesTransfer.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.dnd;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+
+import org.eclipse.swt.dnd.ByteArrayTransfer;
+import org.eclipse.swt.dnd.TransferData;
+
+
+public class ValuesTransfer extends ByteArrayTransfer
+{
+
+ private static final String TYPENAME = "org.apache.directory.ldapstudio.browser.value";
+
+ private static final int TYPEID = registerType( TYPENAME );
+
+ private static ValuesTransfer instance = new ValuesTransfer();
+
+
+ public static ValuesTransfer getInstance()
+ {
+ return instance;
+ }
+
+
+ private ValuesTransfer()
+ {
+ }
+
+
+ public void javaToNative( Object object, TransferData transferData )
+ {
+ if ( object == null || !( object instanceof IValue[] ) )
+ return;
+
+ if ( isSupportedType( transferData ) )
+ {
+ IValue[] values = ( IValue[] ) object;
+ try
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ DataOutputStream writeOut = new DataOutputStream( out );
+
+ for ( int i = 0; i < values.length; i++ )
+ {
+ byte[] connectionName = values[i].getAttribute().getEntry().getConnection().getName().getBytes();
+ writeOut.writeInt( connectionName.length );
+ writeOut.write( connectionName );
+ byte[] dn = values[i].getAttribute().getEntry().getDn().toString().getBytes();
+ writeOut.writeInt( dn.length );
+ writeOut.write( dn );
+ byte[] attributeName = values[i].getAttribute().getDescription().getBytes();
+ writeOut.writeInt( attributeName.length );
+ writeOut.write( attributeName );
+ if ( values[i].isString() )
+ {
+ byte[] value = values[i].getStringValue().getBytes();
+ writeOut.writeBoolean( true );
+ writeOut.writeInt( value.length );
+ writeOut.write( value );
+ }
+ else if ( values[i].isBinary() )
+ {
+ byte[] value = values[i].getBinaryValue();
+ writeOut.writeBoolean( false );
+ writeOut.writeInt( value.length );
+ writeOut.write( value );
+ }
+ }
+
+ byte[] buffer = out.toByteArray();
+ writeOut.close();
+
+ super.javaToNative( buffer, transferData );
+
+ }
+ catch ( IOException e )
+ {
+ }
+ }
+ }
+
+
+ public Object nativeToJava( TransferData transferData )
+ {
+
+ try
+ {
+
+ if ( isSupportedType( transferData ) )
+ {
+
+ byte[] buffer = ( byte[] ) super.nativeToJava( transferData );
+ if ( buffer == null )
+ return null;
+
+ List valueList = new ArrayList();
+ try
+ {
+
+ ByteArrayInputStream in = new ByteArrayInputStream( buffer );
+ DataInputStream readIn = new DataInputStream( in );
+
+ do
+ {
+ IConnection connection = null;
+ if ( readIn.available() > 1 )
+ {
+ int size = readIn.readInt();
+ byte[] connectionName = new byte[size];
+ readIn.read( connectionName );
+ connection = BrowserCorePlugin.getDefault().getConnectionManager().getConnection(
+ new String( connectionName ) );
+ }
+
+ IEntry entry = null;
+ if ( readIn.available() > 1 && connection != null )
+ {
+ int size = readIn.readInt();
+ byte[] dn = new byte[size];
+ readIn.read( dn );
+ entry = connection.getEntryFromCache( new DN( new String( dn ) ) );
+ }
+ else
+ {
+ return null;
+ }
+
+ IAttribute attribute = null;
+ if ( readIn.available() > 1 && entry != null )
+ {
+ int size = readIn.readInt();
+ byte[] attributeName = new byte[size];
+ readIn.read( attributeName );
+ attribute = entry.getAttribute( new String( attributeName ) );
+ }
+ else
+ {
+ return null;
+ }
+
+ IValue value = null;
+ if ( readIn.available() > 1 && attribute != null )
+ {
+ boolean isString = readIn.readBoolean();
+ int size = readIn.readInt();
+ byte[] val = new byte[size];
+ readIn.read( val );
+ String test = new String( val );
+
+ IValue[] values = attribute.getValues();
+ for ( int i = 0; i < values.length; i++ )
+ {
+ if ( isString && values[i].isString() && test.equals( values[i].getStringValue() ) )
+ {
+ value = values[i];
+ break;
+ }
+ else if ( !isString && values[i].isBinary()
+ && test.equals( new String( values[i].getBinaryValue() ) ) )
+ {
+ value = values[i];
+ break;
+ }
+ }
+ }
+ else
+ {
+ return null;
+ }
+
+ if ( value != null )
+ {
+ valueList.add( value );
+ }
+ }
+ while ( readIn.available() > 1 );
+
+ readIn.close();
+ }
+ catch ( IOException ex )
+ {
+ return null;
+ }
+
+ return valueList.isEmpty() ? null : valueList.toArray( new IValue[valueList.size()] );
+ }
+
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+
+ return null;
+
+ }
+
+
+ protected String[] getTypeNames()
+ {
+ return new String[]
+ { TYPENAME };
+ }
+
+
+ protected int[] getTypeIds()
+ {
+ return new int[]
+ { TYPEID };
+ }
+
+}
\ No newline at end of file
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditor.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditor.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditor.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,265 @@
+/*
+ * 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.editors.entry;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.editors.ldif.LdifOutlinePage;
+import org.apache.directory.ldapstudio.browser.ui.views.browser.BrowserView;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidget;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+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.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.INavigationLocation;
+import org.eclipse.ui.INavigationLocationProvider;
+import org.eclipse.ui.IReusableEditor;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.EditorPart;
+import org.eclipse.ui.part.IShowInSource;
+import org.eclipse.ui.part.IShowInTargetList;
+import org.eclipse.ui.part.ShowInContext;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+
+public class EntryEditor extends EditorPart implements INavigationLocationProvider, IReusableEditor
+{
+
+ private EntryEditorConfiguration configuration;
+
+ private EntryEditorActionGroup actionGroup;
+
+ private EntryEditorWidget mainWidget;
+
+ private EntryEditorUniversalListener universalListener;
+
+ private LdifOutlinePage outlinePage;
+
+
+ public static String getId()
+ {
+ return EntryEditor.class.getName();
+ }
+
+
+ public void setInput( IEditorInput input )
+ {
+ super.setInput( input );
+ if ( input instanceof EntryEditorInput && this.universalListener != null )
+ {
+
+ EntryEditorInput eei = ( EntryEditorInput ) input;
+ IEntry entry = eei.getEntry();
+ this.universalListener.setInput( entry );
+ if ( entry != null )
+ {
+ getSite().getPage().getNavigationHistory().markLocation( this );
+ }
+
+ if ( this.outlinePage != null )
+ {
+ this.outlinePage.refresh();
+ }
+ }
+ }
+
+
+ public void init( IEditorSite site, IEditorInput input ) throws PartInitException
+ {
+ this.setInput( input );
+ super.setSite( site );
+ }
+
+
+ public void createPartControl( Composite parent )
+ {
+
+ Composite composite = new Composite( parent, SWT.NONE );
+ composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ // layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
+ composite.setLayout( layout );
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( composite,
+ BrowserUIPlugin.PLUGIN_ID + "." + "tools_entry_editor" );
+
+ // create configuration
+ this.configuration = new EntryEditorConfiguration();
+
+ // create main widget
+ this.mainWidget = new EntryEditorWidget( this.configuration );
+ this.mainWidget.createWidget( composite );
+
+ // create actions and context menu and register global actions
+ this.actionGroup = new EntryEditorActionGroup( this );
+ this.actionGroup.fillToolBar( this.mainWidget.getToolBarManager() );
+ this.actionGroup.fillMenu( this.mainWidget.getMenuManager() );
+ this.actionGroup.enableGlobalActionHandlers( getEditorSite().getActionBars() );
+ this.actionGroup.fillContextMenu( this.mainWidget.getContextMenuManager() );
+
+ // create the listener
+ getSite().setSelectionProvider( this.mainWidget.getViewer() );
+ this.universalListener = new EntryEditorUniversalListener( this );
+ this.setInput( getEditorInput() );
+ }
+
+
+ public void setFocus()
+ {
+ this.mainWidget.setFocus();
+ }
+
+
+ public Object getAdapter( Class required )
+ {
+ if ( IContentOutlinePage.class.equals( required ) )
+ {
+ if ( outlinePage == null || outlinePage.getControl() == null || outlinePage.getControl().isDisposed() )
+ {
+ outlinePage = new LdifOutlinePage( this );
+ }
+ return outlinePage;
+ }
+
+ if ( IShowInTargetList.class.equals( required ) )
+ {
+ return new IShowInTargetList()
+ {
+ public String[] getShowInTargetIds()
+ {
+ return new String[]
+ { BrowserView.getId() };
+ }
+ };
+ }
+
+ if ( IShowInSource.class.equals( required ) )
+ {
+ return new IShowInSource()
+ {
+ public ShowInContext getShowInContext()
+ {
+ return new ShowInContext( getMainWidget().getViewer().getInput(), getMainWidget().getViewer()
+ .getSelection() );
+ }
+ };
+ }
+
+ return super.getAdapter( required );
+ }
+
+
+ public void dispose()
+ {
+
+ EntryEditorManager.editorClosed();
+
+ if ( this.configuration != null )
+ {
+ this.universalListener.dispose();
+ this.universalListener = null;
+ this.mainWidget.dispose();
+ this.mainWidget = null;
+ this.actionGroup.dispose();
+ this.actionGroup = null;
+ this.configuration.dispose();
+ this.configuration = null;
+ getSite().setSelectionProvider( null );
+ }
+
+ super.dispose();
+ }
+
+
+ public void doSave( IProgressMonitor monitor )
+ {
+ }
+
+
+ public void doSaveAs()
+ {
+ }
+
+
+ public boolean isDirty()
+ {
+ return false;
+ }
+
+
+ public boolean isSaveAsAllowed()
+ {
+ return false;
+ }
+
+
+ public EntryEditorActionGroup getActionGroup()
+ {
+ return actionGroup;
+ }
+
+
+ public EntryEditorConfiguration getConfiguration()
+ {
+ return configuration;
+ }
+
+
+ public EntryEditorWidget getMainWidget()
+ {
+ return mainWidget;
+ }
+
+
+ public LdifOutlinePage getOutlinePage()
+ {
+ return outlinePage;
+ }
+
+
+ public EntryEditorUniversalListener getUniversalListener()
+ {
+ return universalListener;
+ }
+
+
+ public INavigationLocation createEmptyNavigationLocation()
+ {
+ System.out.println( "EntryEditor#createEmptyNavigationLocation()" );
+ return null;
+ }
+
+
+ public INavigationLocation createNavigationLocation()
+ {
+ return new EntryEditorNavigationLocation( this );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorActionGroup.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorActionGroup.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorActionGroup.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorActionGroup.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,377 @@
+/*
+ * 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.editors.entry;
+
+
+import java.util.Iterator;
+
+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.apache.directory.ldapstudio.browser.ui.actions.CollapseAllAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.CopyAttributeDescriptionAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.CopyDnAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.CopySearchFilterAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.CopyUrlAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.CopyValueAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.DeleteAllValuesAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.ExpandAllAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.LocateDnInDitAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.NewAttributeAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.NewBatchOperationAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.NewSearchAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.OpenSchemaBrowserAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.RefreshAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.proxy.EntryEditorActionProxy;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EditAttributeDescriptionAction;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidgetActionGroup;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.commands.ActionHandler;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ContributionItemFactory;
+import org.eclipse.ui.commands.ICommandService;
+
+
+public class EntryEditorActionGroup extends EntryEditorWidgetActionGroup
+{
+
+ private ShowOperationalAttributesAction showOperationalAttributesAction;
+
+ private OpenEntryEditorPreferencePageAction openEntryEditorPreferencePage;
+
+ private CollapseAllAction collapseAllAction;
+
+ private ExpandAllAction expandAllAction;
+
+ private EditAttributeDescriptionAction editAttributeDescriptionAction;
+
+ private static final String refreshAttributesAction = "refreshAttributesAction";
+
+ private static final String newAttributeAction = "newAttributeAction";
+
+ private static final String newSearchAction = "newSearchDialogAction";
+
+ private static final String newBatchOperationAction = "newBatchOperationAction";
+
+ private static final String copyDnAction = "copyDnAction";
+
+ private static final String copyUrlAction = "copyUrlAction";
+
+ private static final String copyAttriuteDescriptionAction = "copyAttriuteDescriptionAction";
+
+ private static final String copyValueUtf8Action = "copyValueUtf8Action";
+
+ private static final String copyValueBase64Action = "copyValueBase64Action";
+
+ private static final String copyValueHexAction = "copyValueHexAction";
+
+ private static final String copyValueAsLdifAction = "copyValueAsLdifAction";
+
+ private static final String copySearchFilterAction = "copySearchFilterAction";
+
+ private static final String copyNotSearchFilterAction = "copyNotSearchFilterAction";
+
+ private static final String copyAndSearchFilterAction = "copyAndSearchFilterAction";
+
+ private static final String copyOrSearchFilterAction = "copyOrSearchFilterAction";
+
+ private static final String deleteAllValuesAction = "deleteAllValuesAction";
+
+ private static final String locateDnInDitAction = "locateDnInDitAction";
+
+ private static final String showOcdAction = "showOcdAction";
+
+ private static final String showAtdAction = "showAtdAction";
+
+ private static final String showEqualityMrdAction = "showEqualityMrdAction";
+
+ private static final String showSubstringMrdAction = "showSubstringMrdAction";
+
+ private static final String showOrderingMrdAction = "showOrderingMrdAction";
+
+ private static final String showLsdAction = "showLsdAction";
+
+
+ public EntryEditorActionGroup( EntryEditor entryEditor )
+ {
+ super( entryEditor.getMainWidget(), entryEditor.getConfiguration() );
+ TreeViewer viewer = entryEditor.getMainWidget().getViewer();
+
+ this.openDefaultEditorAction.enableRenameEntryAction();
+
+ this.showOperationalAttributesAction = new ShowOperationalAttributesAction();
+ this.openEntryEditorPreferencePage = new OpenEntryEditorPreferencePageAction();
+ this.collapseAllAction = new CollapseAllAction( viewer );
+ this.expandAllAction = new ExpandAllAction( viewer );
+ this.editAttributeDescriptionAction = new EditAttributeDescriptionAction( viewer );
+
+ this.entryEditorActionMap.put( refreshAttributesAction,
+ new EntryEditorActionProxy( viewer, new RefreshAction() ) );
+
+ this.entryEditorActionMap.put( newAttributeAction,
+ new EntryEditorActionProxy( viewer, new NewAttributeAction() ) );
+ this.entryEditorActionMap.put( newSearchAction, new EntryEditorActionProxy( viewer, new NewSearchAction() ) );
+ this.entryEditorActionMap.put( newBatchOperationAction, new EntryEditorActionProxy( viewer,
+ new NewBatchOperationAction() ) );
+
+ this.entryEditorActionMap.put( locateDnInDitAction, new EntryEditorActionProxy( viewer,
+ new LocateDnInDitAction() ) );
+ this.entryEditorActionMap.put( showOcdAction, new EntryEditorActionProxy( viewer, new OpenSchemaBrowserAction(
+ OpenSchemaBrowserAction.MODE_OBJECTCLASS ) ) );
+ this.entryEditorActionMap.put( showAtdAction, new EntryEditorActionProxy( viewer, new OpenSchemaBrowserAction(
+ OpenSchemaBrowserAction.MODE_ATTRIBUTETYPE ) ) );
+ this.entryEditorActionMap.put( showEqualityMrdAction, new EntryEditorActionProxy( viewer,
+ new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_EQUALITYMATCHINGRULE ) ) );
+ this.entryEditorActionMap.put( showSubstringMrdAction, new EntryEditorActionProxy( viewer,
+ new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_SUBSTRINGMATCHINGRULE ) ) );
+ this.entryEditorActionMap.put( showOrderingMrdAction, new EntryEditorActionProxy( viewer,
+ new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_ORDERINGMATCHINGRULE ) ) );
+ this.entryEditorActionMap.put( showLsdAction, new EntryEditorActionProxy( viewer, new OpenSchemaBrowserAction(
+ OpenSchemaBrowserAction.MODE_SYNTAX ) ) );
+
+ this.entryEditorActionMap.put( copyDnAction, new EntryEditorActionProxy( viewer, new CopyDnAction() ) );
+ this.entryEditorActionMap.put( copyUrlAction, new EntryEditorActionProxy( viewer, new CopyUrlAction() ) );
+ this.entryEditorActionMap.put( copyAttriuteDescriptionAction, new EntryEditorActionProxy( viewer,
+ new CopyAttributeDescriptionAction() ) );
+ this.entryEditorActionMap.put( copyValueUtf8Action, new EntryEditorActionProxy( viewer, new CopyValueAction(
+ CopyValueAction.MODE_UTF8 ) ) );
+ this.entryEditorActionMap.put( copyValueBase64Action, new EntryEditorActionProxy( viewer, new CopyValueAction(
+ CopyValueAction.MODE_BASE64 ) ) );
+ this.entryEditorActionMap.put( copyValueHexAction, new EntryEditorActionProxy( viewer, new CopyValueAction(
+ CopyValueAction.MODE_HEX ) ) );
+ this.entryEditorActionMap.put( copyValueAsLdifAction, new EntryEditorActionProxy( viewer, new CopyValueAction(
+ CopyValueAction.MODE_LDIF ) ) );
+
+ this.entryEditorActionMap.put( copySearchFilterAction, new EntryEditorActionProxy( viewer,
+ new CopySearchFilterAction( CopySearchFilterAction.MODE_EQUALS ) ) );
+ this.entryEditorActionMap.put( copyNotSearchFilterAction, new EntryEditorActionProxy( viewer,
+ new CopySearchFilterAction( CopySearchFilterAction.MODE_NOT ) ) );
+ this.entryEditorActionMap.put( copyAndSearchFilterAction, new EntryEditorActionProxy( viewer,
+ new CopySearchFilterAction( CopySearchFilterAction.MODE_AND ) ) );
+ this.entryEditorActionMap.put( copyOrSearchFilterAction, new EntryEditorActionProxy( viewer,
+ new CopySearchFilterAction( CopySearchFilterAction.MODE_OR ) ) );
+
+ this.entryEditorActionMap.put( deleteAllValuesAction, new EntryEditorActionProxy( viewer,
+ new DeleteAllValuesAction() ) );
+
+ }
+
+
+ public void dispose()
+ {
+ if ( this.showOperationalAttributesAction != null )
+ {
+
+ this.deactivateGlobalActionHandlers();
+
+ this.openEntryEditorPreferencePage = null;
+ this.showOperationalAttributesAction.dispose();
+ this.showOperationalAttributesAction = null;
+ this.expandAllAction.dispose();
+ this.expandAllAction = null;
+ this.collapseAllAction.dispose();
+ this.collapseAllAction = null;
+ this.editAttributeDescriptionAction.dispose();
+ this.editAttributeDescriptionAction = null;
+ }
+
+ super.dispose();
+ }
+
+
+ public void fillToolBar( IToolBarManager toolBarManager )
+ {
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( newValueAction ) );
+ toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( newAttributeAction ) );
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( deleteAction ) );
+ toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( deleteAllValuesAction ) );
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( refreshAttributesAction ) );
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( this.expandAllAction );
+ toolBarManager.add( this.collapseAllAction );
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( this.showQuickFilterAction );
+ toolBarManager.update( true );
+ }
+
+
+ public void fillMenu( IMenuManager menuManager )
+ {
+ menuManager.add( this.openSortDialogAction );
+ menuManager.add( new Separator() );
+ menuManager.add( this.showOperationalAttributesAction );
+ menuManager.add( this.showRawValuesAction );
+ menuManager.add( new Separator() );
+ menuManager.add( this.openEntryEditorPreferencePage );
+ menuManager.addMenuListener( new IMenuListener()
+ {
+ public void menuAboutToShow( IMenuManager manager )
+ {
+ showRawValuesAction.setChecked( BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_SHOW_RAW_VALUES ) );
+ showOperationalAttributesAction.setChecked( BrowserUIPlugin.getDefault().getPreferenceStore()
+ .getBoolean( BrowserUIConstants.PREFERENCE_ENTRYEDITOR_SHOW_OPERATIONAL_ATTRIBUTES ) );
+ }
+ } );
+ menuManager.update( true );
+ }
+
+
+ public void menuAboutToShow( IMenuManager menuManager )
+ {
+
+ // new
+ menuManager.add( ( IAction ) this.entryEditorActionMap.get( newAttributeAction ) );
+ menuManager.add( ( IAction ) this.entryEditorActionMap.get( newValueAction ) );
+ menuManager.add( ( IAction ) this.entryEditorActionMap.get( newSearchAction ) );
+ menuManager.add( ( IAction ) this.entryEditorActionMap.get( newBatchOperationAction ) );
+ menuManager.add( new Separator() );
+
+ // navigation
+ menuManager.add( ( IAction ) this.entryEditorActionMap.get( locateDnInDitAction ) );
+ MenuManager schemaMenuManager = new MenuManager( "Open Schema Browser" );
+ schemaMenuManager.add( ( IAction ) this.entryEditorActionMap.get( showOcdAction ) );
+ schemaMenuManager.add( ( IAction ) this.entryEditorActionMap.get( showAtdAction ) );
+ schemaMenuManager.add( ( IAction ) this.entryEditorActionMap.get( showEqualityMrdAction ) );
+ schemaMenuManager.add( ( IAction ) this.entryEditorActionMap.get( showSubstringMrdAction ) );
+ schemaMenuManager.add( ( IAction ) this.entryEditorActionMap.get( showOrderingMrdAction ) );
+ schemaMenuManager.add( ( IAction ) this.entryEditorActionMap.get( showLsdAction ) );
+ menuManager.add( schemaMenuManager );
+ MenuManager showInSubMenu = new MenuManager( "Show In" );
+ showInSubMenu.add( ContributionItemFactory.VIEWS_SHOW_IN.create( PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow() ) );
+ menuManager.add( showInSubMenu );
+
+ menuManager.add( new Separator() );
+
+ // copy, paste, delete
+ menuManager.add( ( IAction ) this.entryEditorActionMap.get( copyAction ) );
+ menuManager.add( ( IAction ) this.entryEditorActionMap.get( pasteAction ) );
+ menuManager.add( ( IAction ) this.entryEditorActionMap.get( deleteAction ) );
+ menuManager.add( ( IAction ) this.entryEditorActionMap.get( selectAllAction ) );
+ MenuManager advancedMenuManager = new MenuManager( "Advanced" );
+ advancedMenuManager.add( ( IAction ) this.entryEditorActionMap.get( copyDnAction ) );
+ advancedMenuManager.add( ( IAction ) this.entryEditorActionMap.get( copyUrlAction ) );
+ advancedMenuManager.add( new Separator() );
+ advancedMenuManager.add( ( IAction ) this.entryEditorActionMap.get( copyAttriuteDescriptionAction ) );
+ advancedMenuManager.add( new Separator() );
+ advancedMenuManager.add( ( IAction ) this.entryEditorActionMap.get( copyValueUtf8Action ) );
+ advancedMenuManager.add( ( IAction ) this.entryEditorActionMap.get( copyValueBase64Action ) );
+ advancedMenuManager.add( ( IAction ) this.entryEditorActionMap.get( copyValueHexAction ) );
+ advancedMenuManager.add( new Separator() );
+ advancedMenuManager.add( ( IAction ) this.entryEditorActionMap.get( copyValueAsLdifAction ) );
+ advancedMenuManager.add( new Separator() );
+ advancedMenuManager.add( ( IAction ) this.entryEditorActionMap.get( copySearchFilterAction ) );
+ advancedMenuManager.add( ( IAction ) this.entryEditorActionMap.get( copyNotSearchFilterAction ) );
+ advancedMenuManager.add( ( IAction ) this.entryEditorActionMap.get( copyAndSearchFilterAction ) );
+ advancedMenuManager.add( ( IAction ) this.entryEditorActionMap.get( copyOrSearchFilterAction ) );
+ advancedMenuManager.add( new Separator() );
+ advancedMenuManager.add( ( IAction ) this.entryEditorActionMap.get( deleteAllValuesAction ) );
+ menuManager.add( advancedMenuManager );
+ menuManager.add( new Separator() );
+
+ // edit
+ menuManager.add( this.editAttributeDescriptionAction );
+ super.addEditMenu( menuManager );
+ menuManager.add( new Separator() );
+
+ // refresh
+ menuManager.add( ( IAction ) this.entryEditorActionMap.get( refreshAttributesAction ) );
+ menuManager.add( new Separator() );
+
+ // additions
+ menuManager.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
+
+ // properties
+ menuManager.add( ( IAction ) this.entryEditorActionMap.get( propertyDialogAction ) );
+ }
+
+
+ public void activateGlobalActionHandlers()
+ {
+
+ if ( this.actionBars != null )
+ {
+ actionBars.setGlobalActionHandler( ActionFactory.REFRESH.getId(), ( IAction ) this.entryEditorActionMap
+ .get( refreshAttributesAction ) );
+ }
+
+ super.activateGlobalActionHandlers();
+
+ ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+ ICommandService.class );
+ if ( commandService != null )
+ {
+ IAction naa = ( IAction ) this.entryEditorActionMap.get( newAttributeAction );
+ commandService.getCommand( naa.getActionDefinitionId() ).setHandler( new ActionHandler( naa ) );
+ IAction lid = ( IAction ) this.entryEditorActionMap.get( locateDnInDitAction );
+ commandService.getCommand( lid.getActionDefinitionId() ).setHandler( new ActionHandler( lid ) );
+ commandService.getCommand( editAttributeDescriptionAction.getActionDefinitionId() ).setHandler(
+ new ActionHandler( editAttributeDescriptionAction ) );
+ }
+ }
+
+
+ public void deactivateGlobalActionHandlers()
+ {
+
+ if ( this.actionBars != null )
+ {
+ actionBars.setGlobalActionHandler( ActionFactory.REFRESH.getId(), null );
+ }
+
+ super.deactivateGlobalActionHandlers();
+
+ ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+ ICommandService.class );
+ if ( commandService != null )
+ {
+ IAction naa = ( IAction ) this.entryEditorActionMap.get( newAttributeAction );
+ commandService.getCommand( naa.getActionDefinitionId() ).setHandler( null );
+ IAction lid = ( IAction ) this.entryEditorActionMap.get( locateDnInDitAction );
+ commandService.getCommand( lid.getActionDefinitionId() ).setHandler( null );
+ commandService.getCommand( editAttributeDescriptionAction.getActionDefinitionId() ).setHandler( null );
+ }
+ }
+
+
+ public void setInput( IEntry entry )
+ {
+ for ( Iterator it = this.entryEditorActionMap.values().iterator(); it.hasNext(); )
+ {
+ EntryEditorActionProxy action = ( EntryEditorActionProxy ) it.next();
+ action.inputChanged( entry );
+ }
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorConfiguration.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorConfiguration.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorConfiguration.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorConfiguration.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,62 @@
+/*
+ * 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.editors.entry;
+
+
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidget;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidgetConfiguration;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidgetContentProvider;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidgetFilter;
+
+
+public class EntryEditorConfiguration extends EntryEditorWidgetConfiguration
+{
+
+ public EntryEditorConfiguration()
+ {
+ super();
+ }
+
+
+ public void dispose()
+ {
+ super.dispose();
+ }
+
+
+ public EntryEditorWidgetContentProvider getContentProvider( EntryEditorWidget mainWidget )
+ {
+ if ( this.contentProvider == null )
+ this.contentProvider = new EntryEditorContentProvider( this.getPreferences(), mainWidget );
+
+ return contentProvider;
+ }
+
+
+ public EntryEditorWidgetFilter getFilter()
+ {
+ if ( this.filter == null )
+ this.filter = new EntryEditorFilter( getPreferences() );
+
+ return filter;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorContentProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorContentProvider.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorContentProvider.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorContentProvider.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,45 @@
+/*
+ * 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.editors.entry;
+
+
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidget;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidgetContentProvider;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidgetPreferences;
+import org.eclipse.jface.viewers.Viewer;
+
+
+public class EntryEditorContentProvider extends EntryEditorWidgetContentProvider
+{
+
+ public EntryEditorContentProvider( EntryEditorWidgetPreferences layout, EntryEditorWidget mainWidget )
+ {
+ super( layout, mainWidget );
+ }
+
+
+ public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+ {
+ super.inputChanged( viewer, oldInput, newInput );
+
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorFilter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorFilter.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorFilter.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorFilter.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,63 @@
+/*
+ * 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.editors.entry;
+
+
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidgetFilter;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidgetPreferences;
+
+
+public class EntryEditorFilter extends EntryEditorWidgetFilter
+{
+
+ private EntryEditorWidgetPreferences preferences;
+
+
+ public EntryEditorFilter( EntryEditorWidgetPreferences preferences )
+ {
+ this.preferences = preferences;
+ }
+
+
+ public boolean isShowMayAttributes()
+ {
+ return preferences.isShowMayAttributes();
+ }
+
+
+ public boolean isShowMustAttributes()
+ {
+ return preferences.isShowMustAttributes();
+ }
+
+
+ public boolean isShowObjectClassAttribute()
+ {
+ return preferences.isShowObjectClassAttribute();
+ }
+
+
+ public boolean isShowOperationalAttributes()
+ {
+ return preferences.isShowOperationalAttributes();
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorInput.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorInput.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorInput.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,92 @@
+/*
+ * 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.editors.entry;
+
+
+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;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+
+public class EntryEditorInput implements IEditorInput
+{
+
+ private IEntry entry;
+
+
+ public EntryEditorInput( IEntry entry )
+ {
+ this.entry = entry;
+ }
+
+
+ public boolean exists()
+ {
+ return false;
+ }
+
+
+ public ImageDescriptor getImageDescriptor()
+ {
+ return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ATTRIBUTE );
+ }
+
+
+ public String getName()
+ {
+ return "Entry Editor";
+ }
+
+
+ public String getToolTipText()
+ {
+ return this.entry != null ? this.entry.getDn().toString() : "";
+ }
+
+
+ public IPersistableElement getPersistable()
+ {
+ return null;
+ }
+
+
+ public Object getAdapter( Class adapter )
+ {
+ return null;
+ }
+
+
+ public IEntry getEntry()
+ {
+ return entry;
+ }
+
+
+ public boolean equals( Object obj )
+ {
+ return obj instanceof EntryEditorInput;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorManager.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorManager.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorManager.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorManager.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,73 @@
+/*
+ * 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.editors.entry;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+
+public class EntryEditorManager
+{
+
+ private static EntryEditor editor;
+
+
+ public static void setInput( IEntry entry )
+ {
+
+ IEditorInput input = new EntryEditorInput( entry );
+
+ if ( editor == null && entry != null )
+ {
+ try
+ {
+ editor = ( EntryEditor ) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .openEditor( input, EntryEditor.getId(), false );
+ }
+ catch ( PartInitException e )
+ {
+ e.printStackTrace();
+ }
+ }
+ else if ( editor != null )
+ {
+ editor.setInput( input );
+ if ( entry != null )
+ {
+ if ( !PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().isPartVisible( editor ) )
+ {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop( editor );
+ }
+ }
+ }
+ }
+
+
+ static void editorClosed()
+ {
+ editor = null;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorNavigationLocation.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorNavigationLocation.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorNavigationLocation.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorNavigationLocation.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,125 @@
+/*
+ * 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.editors.entry;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.NameException;
+
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.INavigationLocation;
+import org.eclipse.ui.NavigationLocation;
+
+
+public class EntryEditorNavigationLocation extends NavigationLocation
+{
+
+ protected EntryEditorNavigationLocation( EntryEditor editor )
+ {
+ super( editor );
+ }
+
+
+ public String getText()
+ {
+ IEntry entry = getEntry();
+ if ( entry != null )
+ {
+ return entry.getDn().toString();
+ }
+ else
+ {
+ return super.getText();
+ }
+ }
+
+
+ public void saveState( IMemento memento )
+ {
+ IEntry entry = getEntry();
+ memento.putString( "DN", entry.getDn().toString() );
+ memento.putString( "CONNECTION", entry.getConnection().getName() );
+ }
+
+
+ public void restoreState( IMemento memento )
+ {
+ try
+ {
+ IConnection connection = BrowserCorePlugin.getDefault().getConnectionManager().getConnection(
+ memento.getString( "CONNECTION" ) );
+ DN dn = new DN( memento.getString( "DN" ) );
+ IEntry entry = connection.getEntryFromCache( dn );
+ super.setInput( new EntryEditorInput( entry ) );
+ }
+ catch ( NameException e )
+ {
+ e.printStackTrace();
+ }
+
+ }
+
+
+ public void restoreLocation()
+ {
+ IEditorPart editorPart = getEditorPart();
+ if ( editorPart != null && editorPart instanceof EntryEditor )
+ {
+ EntryEditor entryEditor = ( EntryEditor ) editorPart;
+ entryEditor.setInput( ( EntryEditorInput ) getInput() );
+ }
+ }
+
+
+ public boolean mergeInto( INavigationLocation currentLocation )
+ {
+ return false;
+ }
+
+
+ public void update()
+ {
+
+ }
+
+
+ private IEntry getEntry()
+ {
+
+ Object editorInput = getInput();
+ if ( editorInput != null && editorInput instanceof EntryEditorInput )
+ {
+ EntryEditorInput entryEditorInput = ( EntryEditorInput ) editorInput;
+ IEntry entry = entryEditorInput.getEntry();
+ if ( entry != null )
+ {
+ return entry;
+ }
+ }
+
+ return null;
+ }
+
+}