directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r524625 - in /directory/ldapstudio/trunk/ldapstudio-browser-ui: ./ src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/ src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/
Date Sun, 01 Apr 2007 16:24:59 GMT
Author: seelmann
Date: Sun Apr  1 09:24:54 2007
New Revision: 524625

URL: http://svn.apache.org/viewvc?view=rev&rev=524625
Log:
Added AttributeTypeAndValueValueEditor, Updated some icons.

Added:
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/AttributeTypeAndValueDialog.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/AttributeTypeAndValueValueEditor.java
Modified:
    directory/ldapstudio/trunk/ldapstudio-browser-ui/plugin.xml
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/AttributeTypeDialog.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterDialog.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterWidgetDialog.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/ObjectClassDialog.java

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/plugin.xml
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/plugin.xml?view=diff&rev=524625&r1=524624&r2=524625
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/plugin.xml (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/plugin.xml Sun Apr  1 09:24:54 2007
@@ -737,7 +737,7 @@
     </valueEditor>
     <valueEditor
           class="org.apache.directory.ldapstudio.browser.ui.valueeditors.internal.ObjectClassValueEditor"
-          icon="icons/inplace_oceditor.gif"
+          icon="icons/ocd.png"
           name="Object Class Editor">
        <attribute attributeType="objectClass"/>
     </valueEditor>

Added: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/AttributeTypeAndValueDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/AttributeTypeAndValueDialog.java?view=auto&rev=524625
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/AttributeTypeAndValueDialog.java
(added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/AttributeTypeAndValueDialog.java
Sun Apr  1 09:24:54 2007
@@ -0,0 +1,209 @@
+/*
+ *  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 java.util.Arrays;
+
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+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.ListContentProposalProvider;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.fieldassist.ComboContentAdapter;
+import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+import org.eclipse.jface.fieldassist.DecoratedField;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.fieldassist.IControlCreator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+/**
+ * This class provides a dialog to enter an attribute type and value.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeTypeAndValueDialog extends Dialog
+{
+
+    /** The dialog title */
+    public static final String DIALOG_TITLE = "Attribute Type and Value Editor";
+
+    /** The schema. */
+    private Schema schema;
+
+    /** The initial attribute type. */
+    private String initialAttributeType;
+
+    /** The initial value. */
+    private String initialValue;
+
+    /** The attribute type combo field. */
+    private DecoratedField attributeTypeComboField;
+
+    /** The attribute type combo. */
+    private Combo attributeTypeCombo;
+
+    /** The attribute type content proposal adapter */
+    private ContentProposalAdapter attributeTypeCPA;
+
+    /** The value text. */
+    private Text valueText;
+
+    /** The return attribute type. */
+    private String returnAttributeType;
+
+    /** The return value. */
+    private String returnValue;
+
+
+    /**
+     * Creates a new instance of AttributeTypeDialog.
+     * 
+     * @param parentShell the parent shell
+     * @param schema the schema
+     * @param initialAttributeType the initial attribute type
+     * @param initialValue the initial value
+     */
+    public AttributeTypeAndValueDialog( Shell parentShell, Schema schema, String initialAttributeType,
+        String initialValue )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        this.initialAttributeType = initialAttributeType;
+        this.initialValue = initialValue;
+        this.schema = schema;
+        this.returnValue = null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( DIALOG_TITLE );
+        shell.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_TEXTEDITOR
) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        super.createButtonsForButtonBar( parent );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void okPressed()
+    {
+        returnAttributeType = attributeTypeCombo.getText();
+        returnValue = valueText.getText();
+        super.okPressed();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected Control createDialogArea( Composite parent )
+    {
+        // create composite
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH
);
+        composite.setLayoutData( gd );
+        composite.setLayout( new GridLayout( 3, false ) );
+
+        // combo widget
+        String[] allAtNames = schema.getAttributeTypeDescriptionNames();
+        Arrays.sort( allAtNames );
+
+        final FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(
+            FieldDecorationRegistry.DEC_CONTENT_PROPOSAL );
+        attributeTypeComboField = new DecoratedField( composite, SWT.NONE, new IControlCreator()
+        {
+            public Control createControl( Composite parent, int style )
+            {
+                Combo combo = BaseWidgetUtils.createCombo( parent, new String[0], -1, 1 );
+                combo.setVisibleItemCount( 20 );
+                return combo;
+            }
+        } );
+        attributeTypeComboField.addFieldDecoration( fieldDecoration, SWT.TOP | SWT.LEFT,
true );
+        attributeTypeComboField.getLayoutControl().setLayoutData( new GridData( SWT.FILL,
SWT.CENTER, true, false ) );
+        attributeTypeCombo = ( Combo ) attributeTypeComboField.getControl();
+        attributeTypeCombo.setItems( allAtNames );
+        attributeTypeCombo.setText( initialAttributeType );
+
+        // content proposal adapter
+        attributeTypeCPA = new ContentProposalAdapter( attributeTypeCombo, new ComboContentAdapter(),
+            new ListContentProposalProvider( attributeTypeCombo.getItems() ), null, null
);
+        attributeTypeCPA.setFilterStyle( ContentProposalAdapter.FILTER_NONE );
+        attributeTypeCPA.setProposalAcceptanceStyle( ContentProposalAdapter.PROPOSAL_REPLACE
);
+
+        BaseWidgetUtils.createLabel( composite, " = ", 1 );
+
+        valueText = BaseWidgetUtils.createText( composite, initialValue, 1 );
+
+        applyDialogFont( composite );
+        return composite;
+    }
+
+
+    /**
+     * Gets the attribute type.
+     * 
+     * @return the attribute type, null if canceled
+     */
+    public String getAttributeType()
+    {
+        return returnAttributeType;
+    }
+
+
+    /**
+     * Gets the value.
+     * 
+     * @return the value, null if canceled
+     */
+    public String getValue()
+    {
+        return returnValue;
+    }
+
+}

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/AttributeTypeDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/AttributeTypeDialog.java?view=diff&rev=524625&r1=524624&r2=524625
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/AttributeTypeDialog.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/AttributeTypeDialog.java
Sun Apr  1 09:24:54 2007
@@ -100,7 +100,7 @@
     {
         super.configureShell( shell );
         shell.setText( DIALOG_TITLE );
-        shell.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_TEXTEDITOR
) );
+        shell.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_ATD
) );
     }
 
 

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterDialog.java?view=diff&rev=524625&r1=524624&r2=524625
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterDialog.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterDialog.java
Sun Apr  1 09:24:54 2007
@@ -23,6 +23,8 @@
 
 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.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
 import org.apache.directory.ldapstudio.browser.ui.editors.filter.FilterSourceViewerConfiguration;
 
 import org.eclipse.jface.dialogs.Dialog;
@@ -79,6 +81,7 @@
     {
         super.configureShell( newShell );
         newShell.setText( this.title != null ? this.title : DIALOG_TITLE );
+        newShell.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_FILTER_EQUALS
) );
     }
 
 

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterWidgetDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterWidgetDialog.java?view=diff&rev=524625&r1=524624&r2=524625
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterWidgetDialog.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterWidgetDialog.java
Sun Apr  1 09:24:54 2007
@@ -22,6 +22,8 @@
 
 
 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.search.FilterWidget;
 
 import org.eclipse.jface.dialogs.Dialog;
@@ -92,6 +94,7 @@
     {
         super.configureShell( newShell );
         newShell.setText( title );
+        newShell.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_FILTER_EQUALS
) );
     }
 
 

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/ObjectClassDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/ObjectClassDialog.java?view=diff&rev=524625&r1=524624&r2=524625
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/ObjectClassDialog.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/ObjectClassDialog.java
Sun Apr  1 09:24:54 2007
@@ -100,7 +100,7 @@
     {
         super.configureShell( shell );
         shell.setText( DIALOG_TITLE );
-        shell.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_TEXTEDITOR
) );
+        shell.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_OCD
) );
     }
 
 

Added: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/AttributeTypeAndValueValueEditor.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/AttributeTypeAndValueValueEditor.java?view=auto&rev=524625
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/AttributeTypeAndValueValueEditor.java
(added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/AttributeTypeAndValueValueEditor.java
Sun Apr  1 09:24:54 2007
@@ -0,0 +1,178 @@
+/*
+ *  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.valueeditors.internal;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.AttributeTypeAndValueDialog;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.TextDialog;
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogStringValueEditor;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Implementation of IValueEditor for attribute type and value.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeTypeAndValueValueEditor extends AbstractDialogStringValueEditor
+{
+
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation opens the AttributeTypeDialog.
+     */
+    public boolean openDialog( Shell shell )
+    {
+        Object value = getValue();
+        if ( value != null && value instanceof AttributeTypeAndValueValueEditorRawValueWrapper
)
+        {
+            AttributeTypeAndValueValueEditorRawValueWrapper wrapper = ( AttributeTypeAndValueValueEditorRawValueWrapper
) value;
+            AttributeTypeAndValueDialog dialog = new AttributeTypeAndValueDialog( shell,
wrapper.schema, wrapper.attributeType, wrapper.value );
+            if ( dialog.open() == TextDialog.OK && !"".equals( dialog.getAttributeType()
) && !"".equals( dialog.getValue() ) )
+            {
+                setValue( dialog.getAttributeType() + '=' + dialog.getValue() );
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     * 
+     * Returns always the string value.
+     * 
+     * Reimplementation, because getRawValue() returns an 
+     * AttributeTypeValueEditorRawValueWrapper.
+     */
+    public String getDisplayValue( IValue value )
+    {
+        if ( value == null )
+        {
+            return "NULL";
+        }
+
+        String displayValue = value.getStringValue();
+        return displayValue;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     * 
+     * Returns null.
+     * Modification in search result editor not supported.
+     */
+    public Object getRawValue( AttributeHierarchy attributeHierarchy )
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     * 
+     * Returns an AttributeTypeAndValueValueEditorRawValueWrapper.
+     */
+    public Object getRawValue( IValue value )
+    {
+        if ( value == null || !value.isString() )
+        {
+            return null;
+        }
+        else
+        {
+            return getRawValue( value.getAttribute().getEntry().getConnection(), value.getStringValue()
);
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     * 
+     * Returns an AttributeTypeAndValueValueEditorRawValueWrapper.
+     */
+    public Object getRawValue( IConnection connection, Object value )
+    {
+        Schema schema = null;
+        if ( connection != null )
+        {
+            schema = connection.getSchema();
+        }
+        if ( schema == null || value == null || !( value instanceof String ) )
+        {
+            return null;
+        }
+
+        String atavValue = ( String ) value;
+        String[] atav = atavValue.split( "=", 2 );
+        String at = atav.length > 0 ? atav[0] : "";
+        String v = atav.length > 1 ? atav[1] : "";
+        AttributeTypeAndValueValueEditorRawValueWrapper wrapper = new AttributeTypeAndValueValueEditorRawValueWrapper(
schema, at, v );
+        return wrapper;
+    }
+
+    /**
+     * The AttributeTypeAndValueValueEditorRawValueWrapper is used to pass contextual 
+     * information to the opened AttributeTypeAndValueDialog.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
+    private class AttributeTypeAndValueValueEditorRawValueWrapper
+    {
+        /** 
+         * The schema, used in AttributeTypeDialog to build the list
+         * with possible attribute types.
+         */
+        private Schema schema;
+
+        /** The attribute type, used as initial attribute type. */
+        private String attributeType;
+        
+        /** The value, used as initial value. */
+        private String value;
+
+
+        /**
+         * Creates a new instance of AttributeTypeAndValueValueEditorRawValueWrapper.
+         * 
+         * @param schema the schema
+         * @param attributeType the attribute type
+         * @param value the value
+         */
+        private AttributeTypeAndValueValueEditorRawValueWrapper( Schema schema, String attributeType,
String value )
+        {
+            super();
+            this.schema = schema;
+            this.attributeType = attributeType;
+            this.value = value;
+        }
+    }
+
+}



Mime
View raw message