You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2007/07/02 00:13:59 UTC
svn commit: r552368 - in /directory/studio/trunk:
studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/valueeditors/
studio-ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/
Author: seelmann
Date: Sun Jul 1 15:13:58 2007
New Revision: 552368
URL: http://svn.apache.org/viewvc?view=rev&rev=552368
Log:
Simplified IValueEditor interface
Modified:
directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/valueeditors/IValueEditor.java
directory/studio/trunk/studio-ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/AbstractOpenValueEditorAction.java
directory/studio/trunk/studio-ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/OpenBestValueEditorAction.java
Modified: directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/valueeditors/IValueEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/valueeditors/IValueEditor.java?view=diff&rev=552368&r1=552367&r2=552368
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/valueeditors/IValueEditor.java (original)
+++ directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/valueeditors/IValueEditor.java Sun Jul 1 15:13:58 2007
@@ -22,7 +22,6 @@
import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy;
-import org.apache.directory.studio.ldapbrowser.core.model.IConnection;
import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
import org.apache.directory.studio.ldapbrowser.core.model.IValue;
import org.apache.directory.studio.ldapbrowser.core.model.ModelModificationException;
@@ -105,24 +104,6 @@
* @return the raw value of the value or null
*/
public abstract Object getRawValue( IValue value );
-
-
- /**
- * Returns the raw value if this value editor can handle the given
- * value. The returned value is used as input for the CellEditor
- * returned by getCellEditor().
- * <p>
- * If this value editor can't handle the given value it must
- * return null.
- * <p>
- * This method is called from the LDIF editor. The connection object
- * could be used for editors handling connection-dependent values.
- *
- * @param connection the connection
- * @param stringOrBinaryValue the value either String or byte[]
- * @return the raw value of the value or null
- */
- public abstract Object getRawValue( IConnection connection, Object stringOrBinaryValue );
/**
Modified: directory/studio/trunk/studio-ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/AbstractOpenValueEditorAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/AbstractOpenValueEditorAction.java?view=diff&rev=552368&r1=552367&r2=552368
==============================================================================
--- directory/studio/trunk/studio-ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/AbstractOpenValueEditorAction.java (original)
+++ directory/studio/trunk/studio-ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/AbstractOpenValueEditorAction.java Sun Jul 1 15:13:58 2007
@@ -21,9 +21,17 @@
package org.apache.directory.studio.ldifeditor.editor.actions;
+import org.apache.directory.studio.ldapbrowser.core.internal.model.Attribute;
import org.apache.directory.studio.ldapbrowser.core.internal.model.DummyConnection;
+import org.apache.directory.studio.ldapbrowser.core.internal.model.DummyEntry;
+import org.apache.directory.studio.ldapbrowser.core.internal.model.Value;
+import org.apache.directory.studio.ldapbrowser.core.model.DN;
import org.apache.directory.studio.ldapbrowser.core.model.IConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.ModelModificationException;
+import org.apache.directory.studio.ldapbrowser.core.model.NameException;
import org.apache.directory.studio.ldapbrowser.core.model.ldif.LdifPart;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifContainer;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifRecord;
import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifAttrValLine;
import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifControlLine;
import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifDeloldrdnLine;
@@ -133,18 +141,51 @@
protected Object getValueEditorRawValue()
{
- Object rawValue = null;
+ IConnection connection = getConnection();
+ String dn = getDn();
+ String description = getAttributeDescription();
Object value = getValue();
+
+ Object rawValue = null;
if ( value != null )
{
- IConnection connection = getConnection();
- rawValue = valueEditor.getRawValue( connection, value );
+ try
+ {
+ DummyEntry dummyEntry = new DummyEntry( new DN( dn ), connection );
+ Attribute dummyAttribute = new Attribute( dummyEntry, description );
+ Value dummyValue = new Value( dummyAttribute, value );
+
+ rawValue = valueEditor.getRawValue( dummyValue );
+ }
+ catch ( NameException e )
+ {
+ e.printStackTrace();
+ }
+ catch ( ModelModificationException e )
+ {
+ e.printStackTrace();
+ }
}
return rawValue;
}
+ protected String getDn()
+ {
+ LdifContainer[] selectedLdifContainers = getSelectedLdifContainers();
+ String dn = null;
+ if ( selectedLdifContainers.length == 1 && selectedLdifContainers[0] instanceof LdifRecord )
+ {
+ LdifRecord record = ( LdifRecord ) selectedLdifContainers[0];
+ LdifDnLine dnLine = record.getDnLine();
+ dn = dnLine.getUnfoldedDn();
+
+ }
+ return dn;
+ }
+
+
protected Object getValue()
{
LdifPart[] parts = getSelectedLdifParts();
Modified: directory/studio/trunk/studio-ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/OpenBestValueEditorAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/OpenBestValueEditorAction.java?view=diff&rev=552368&r1=552367&r2=552368
==============================================================================
--- directory/studio/trunk/studio-ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/OpenBestValueEditorAction.java (original)
+++ directory/studio/trunk/studio-ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/OpenBestValueEditorAction.java Sun Jul 1 15:13:58 2007
@@ -38,18 +38,16 @@
public void update()
{
-
super.setEnabled( isEditableLineSelected() );
// determine value editor
IConnection connection = getConnection();
String attributeDescription = getAttributeDescription();
- Object oldValue = getValue();
if ( attributeDescription != null )
{
valueEditor = valueEditorManager.getCurrentValueEditor( connection.getSchema(), attributeDescription );
- Object rawValue = valueEditor.getRawValue( connection, oldValue );
+ Object rawValue = getValueEditorRawValue();
if ( !( valueEditor instanceof AbstractDialogValueEditor ) || rawValue == null )
{
IValueEditor[] vps = valueEditorManager.getAlternativeValueEditors( connection.getSchema(), attributeDescription );
@@ -57,7 +55,7 @@
&& ( !( valueEditor instanceof AbstractDialogValueEditor ) || rawValue == null ); i++ )
{
valueEditor = vps[i];
- rawValue = valueEditor.getRawValue( connection, oldValue );
+ rawValue = getValueEditorRawValue();
}
}
}