directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r524584 - in /directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui: actions/ dialogs/ valueeditors/internal/
Date Sun, 01 Apr 2007 11:28:10 GMT
Author: seelmann
Date: Sun Apr  1 04:28:09 2007
New Revision: 524584

URL: http://svn.apache.org/viewvc?view=rev&rev=524584
Log:
Renamed FilterChildrenDialog to FilterWidgetDialog, Added FilterValueEditor

Added:
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterWidgetDialog.java
      - copied, changed from r524301, directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterChildrenDialog.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/FilterValueEditor.java
Removed:
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterChildrenDialog.java
Modified:
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/actions/FilterChildrenAction.java

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/actions/FilterChildrenAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/actions/FilterChildrenAction.java?view=diff&rev=524584&r1=524583&r2=524584
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/actions/FilterChildrenAction.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/actions/FilterChildrenAction.java
Sun Apr  1 04:28:09 2007
@@ -25,7 +25,7 @@
 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.dialogs.FilterChildrenDialog;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.FilterWidgetDialog;
 
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.resource.ImageDescriptor;
@@ -58,7 +58,7 @@
     {
         if ( getSelectedEntries().length == 1 )
         {
-            FilterChildrenDialog dialog = new FilterChildrenDialog( getShell(), getSelectedEntries()[0]
+            FilterWidgetDialog dialog = new FilterWidgetDialog( getShell(), "Filter Children",
getSelectedEntries()[0]
                 .getChildrenFilter(), getSelectedEntries()[0].getConnection() );
             if ( dialog.open() == Dialog.OK )
             {

Copied: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterWidgetDialog.java
(from r524301, directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterChildrenDialog.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=524584&p1=directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterChildrenDialog.java&r1=524301&p2=directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterWidgetDialog.java&r2=524584
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterChildrenDialog.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/dialogs/FilterWidgetDialog.java
Sun Apr  1 04:28:09 2007
@@ -35,17 +35,16 @@
 
 
 /**
- * This dialog is used to enter a LDAP filter to filter the child nodes
- * of an entry.
+ * This dialog is used to enter a LDAP filter.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class FilterChildrenDialog extends Dialog
+public class FilterWidgetDialog extends Dialog
 {
 
     /** The title */
-    public static final String DIALOG_TITLE = "Filter Children";
+    private String title;
 
     /** The connection, used for attribute completion. */
     private IConnection connection;
@@ -58,15 +57,17 @@
 
 
     /**
-     * Creates a new instance of FilterChildrenDialog.
-     *
+     * Creates a new instance of FilterWidgetDialog.
+     * 
      * @param parentShell the parent shell
+     * @param title the dialog's title
      * @param filter the inital filter
      * @param connection the connection, used for attribute completion
      */
-    public FilterChildrenDialog( Shell parentShell, String filter, IConnection connection
)
+    public FilterWidgetDialog( Shell parentShell, String title, String filter, IConnection
connection )
     {
         super( parentShell );
+        this.title = title;
         this.filter = filter;
         this.connection = connection;
         setShellStyle( SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE );
@@ -80,7 +81,7 @@
      */
     public String getFilter()
     {
-        return this.filter;
+        return filter;
     }
 
 
@@ -90,7 +91,7 @@
     protected void configureShell( Shell newShell )
     {
         super.configureShell( newShell );
-        newShell.setText( DIALOG_TITLE );
+        newShell.setText( title );
     }
 
 
@@ -101,7 +102,7 @@
     {
         if ( buttonId == IDialogConstants.OK_ID )
         {
-            this.filter = filterWidget.getFilter();
+            filter = filterWidget.getFilter();
             filterWidget.saveDialogSettings();
         }
 

Added: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/FilterValueEditor.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/FilterValueEditor.java?view=auto&rev=524584
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/FilterValueEditor.java
(added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/FilterValueEditor.java
Sun Apr  1 04:28:09 2007
@@ -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.valueeditors.internal;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.FilterWidgetDialog;
+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 LDAP filters.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class FilterValueEditor extends AbstractDialogStringValueEditor
+{
+
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation opens the TextDialog.
+     */
+    public boolean openDialog( Shell shell )
+    {
+        Object value = getValue();
+        if ( value != null && value instanceof FilterValueEditorRawValueWrapper )
+        {
+            FilterValueEditorRawValueWrapper wrapper = ( FilterValueEditorRawValueWrapper
) value;
+            FilterWidgetDialog dialog = new FilterWidgetDialog( shell, "Filter Editor", wrapper.filter,
+                wrapper.connection );
+            if ( dialog.open() == TextDialog.OK && !"".equals( dialog.getFilter()
) )
+            {
+                setValue( dialog.getFilter() );
+                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 a FilterValueEditorRawValueWrapper.
+     */
+    public Object getRawValue( IValue value )
+    {
+        if ( value == null || !value.isString() )
+        {
+            return null;
+        }
+        else
+        {
+            return getRawValue( value.getAttribute().getEntry().getConnection(), value.getStringValue()
);
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     * 
+     * Returns a FilterValueEditorRawValueWrapper.
+     */
+    public Object getRawValue( IConnection connection, Object value )
+    {
+        if ( connection == null || value == null || !( value instanceof String ) )
+        {
+            return null;
+        }
+
+        String filterValue = ( String ) value;
+        FilterValueEditorRawValueWrapper wrapper = new FilterValueEditorRawValueWrapper(
connection, filterValue );
+        return wrapper;
+    }
+
+    /**
+     * The FilterValueEditorRawValueWrapper is used to pass contextual 
+     * information to the opened FilterDialog.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
+    private class FilterValueEditorRawValueWrapper
+    {
+        /** 
+         * The connection, used in FilterDialog to build the list
+         * with possible attribute types.
+         */
+        private IConnection connection;
+
+        /** The filter, used as initial value in FilterDialog. */
+        private String filter;
+
+
+        /**
+         * Creates a new instance of FilterValueEditorRawValueWrapper.
+         *
+         * @param schema the schema
+         * @param attributeType the attribute type
+         */
+        private FilterValueEditorRawValueWrapper( IConnection connection, String filter )
+        {
+            this.connection = connection;
+            this.filter = filter;
+        }
+    }
+}



Mime
View raw message