directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r567084 - in /directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor: controller/actions/ view/dialogs/ view/search/ view/views/
Date Fri, 17 Aug 2007 16:47:12 GMT
Author: pamarcelot
Date: Fri Aug 17 09:47:11 2007
New Revision: 567084

URL: http://svn.apache.org/viewvc?view=rev&rev=567084
Log:
Added PreviousSearchesDialog.
Updated Search Actions.

Added:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/dialogs/PreviousSearchesDialog.java
Modified:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/ShowSearchHistoryAction.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/search/SearchPage.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProblemsView.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchView.java

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/ShowSearchHistoryAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/ShowSearchHistoryAction.java?view=diff&rev=567084&r1=567083&r2=567084
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/ShowSearchHistoryAction.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/ShowSearchHistoryAction.java
Fri Aug 17 09:47:11 2007
@@ -22,6 +22,7 @@
 
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
+import org.apache.directory.studio.apacheds.schemaeditor.view.dialogs.PreviousSearchesDialog;
 import org.apache.directory.studio.apacheds.schemaeditor.view.search.SearchPage;
 import org.apache.directory.studio.apacheds.schemaeditor.view.views.SearchView;
 import org.eclipse.jface.action.Action;
@@ -29,6 +30,9 @@
 import org.eclipse.jface.action.IMenuCreator;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.MenuItem;
@@ -72,7 +76,8 @@
      */
     public void run()
     {
-        System.out.println( "run" );
+        PreviousSearchesDialog dialog = new PreviousSearchesDialog();
+        dialog.open();
     }
 
 
@@ -138,6 +143,7 @@
     {
         menu = new Menu( parent );
 
+        // Previous searches 
         String[] previousSearches = SearchPage.loadSearchStringHistory();
         for ( String search : previousSearches )
         {
@@ -147,13 +153,27 @@
                 PluginConstants.IMG_SEARCH_HISTORY_ITEM ).createImage() );
         }
 
-        if ( previousSearches.length > 0 )
+        // No search history
+        if ( previousSearches.length == 0 )
         {
-            new MenuItem( menu, SWT.SEPARATOR );
+            MenuItem item = new MenuItem( menu, SWT.RADIO );
+            item.setText( "(None)" );
+            item.setEnabled( false );
         }
-        
+
+        // Menu Separator
+        new MenuItem( menu, SWT.SEPARATOR );
+
         MenuItem item = new MenuItem( menu, SWT.PUSH );
         item.setText( "History..." );
+        item.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                PreviousSearchesDialog dialog = new PreviousSearchesDialog();
+                dialog.open();
+            }
+        } );
         item = new MenuItem( menu, SWT.PUSH );
         item.setText( "Clear History" );
 

Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/dialogs/PreviousSearchesDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/dialogs/PreviousSearchesDialog.java?view=auto&rev=567084
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/dialogs/PreviousSearchesDialog.java
(added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/dialogs/PreviousSearchesDialog.java
Fri Aug 17 09:47:11 2007
@@ -0,0 +1,131 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.schemaeditor.view.dialogs;
+
+
+import org.apache.directory.studio.apacheds.schemaeditor.Activator;
+import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
+import org.apache.directory.studio.apacheds.schemaeditor.view.search.SearchPage;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This dialog is used to display the previous searches.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PreviousSearchesDialog extends Dialog
+{
+    // UI Fields
+    private TableViewer tableViewer;
+
+
+    /**
+     * Creates a new instance of PreviousSearchesDialog.
+     */
+    public PreviousSearchesDialog()
+    {
+        super( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
+    protected void configureShell( Shell newShell )
+    {
+        super.configureShell( newShell );
+        newShell.setText( "Previous Searches" );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+     */
+    protected Control createDialogArea( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NONE );
+        composite.setLayout( new GridLayout( 2, false ) );
+        composite.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true )
);
+
+        Label label = new Label( composite, SWT.NONE );
+        label.setText( "Select the search to show in the search results view:" );
+        label.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+
+        tableViewer = new TableViewer( composite );
+        GridData gd = new GridData( SWT.FILL, SWT.NONE, true, false );
+        gd.widthHint = 300;
+        gd.heightHint = 200;
+        tableViewer.getTable().setLayoutData( gd );
+        tableViewer.setContentProvider( new ArrayContentProvider() );
+        tableViewer.setLabelProvider( new LabelProvider()
+        {
+            @Override
+            public Image getImage( Object element )
+            {
+                return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_SEARCH_HISTORY_ITEM ).createImage();
+            }
+        } );
+
+        Button removeButton = new Button( composite, SWT.NONE );
+        removeButton.setText( "Remove" );
+        removeButton.setLayoutData( new GridData( SWT.NONE, SWT.BEGINNING, false, false )
);
+
+        initTableViewer();
+
+        return composite;
+    }
+
+
+    /**
+     * Initializes the TableViewer.
+     */
+    private void initTableViewer()
+    {
+        tableViewer.setInput( SearchPage.loadSearchStringHistory() );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+     */
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL,
false );
+        createButton( parent, IDialogConstants.OK_ID, "Open", true );
+    }
+}

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/search/SearchPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/search/SearchPage.java?view=diff&rev=567084&r1=567083&r2=567084
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/search/SearchPage.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/search/SearchPage.java
Fri Aug 17 09:47:11 2007
@@ -27,6 +27,8 @@
 
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
+import org.apache.directory.studio.apacheds.schemaeditor.view.views.SchemaView;
+import org.apache.directory.studio.apacheds.schemaeditor.view.views.SearchView;
 import org.eclipse.jface.dialogs.DialogPage;
 import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.search.ui.ISearchPage;
@@ -41,6 +43,7 @@
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.PartInitException;
 
 
 /**
@@ -171,6 +174,8 @@
 
         initSearchScope();
 
+        searchCombo.setFocus();
+
         super.setControl( parent );
     }
 
@@ -273,11 +278,22 @@
             searchScope.add( SearchScopeEnum.OPTIONAL_ATTRIBUTES );
         }
 
-        //
-        //        searchView.setSearch( searchCombo.getText(), scope );
-
-        saveSearchScope( searchScope );
+        // Saving search String and Search Scope to dialings settings
         addSearchStringHistory( searchCombo.getText() );
+        saveSearchScope( searchScope );
+
+        // Opening the SearchView and displaying the results
+        try
+        {
+            SearchView searchView = ( SearchView ) Activator.getDefault().getWorkbench().getActiveWorkbenchWindow()
+                .getActivePage().showView( SearchView.ID );
+            searchView.setSearchInput( searchCombo.getText(), searchScope.toArray( new SearchScopeEnum[0]
) );
+        }
+        catch ( PartInitException e )
+        {
+            // TODO ADD Logger
+            e.printStackTrace();
+        }
 
         return true;
     }

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProblemsView.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProblemsView.java?view=diff&rev=567084&r1=567083&r2=567084
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProblemsView.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProblemsView.java
Fri Aug 17 09:47:11 2007
@@ -158,7 +158,7 @@
 
 
     /**
-     * Refresh the overview label with the number of errors and warnings
+     * Refresh the overview label with the number of errors and warnings.
      *
      * @param errors
      *      the number of errors
@@ -195,5 +195,4 @@
 
         overviewLabel.setText( sb.toString() );
     }
-
 }

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchView.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchView.java?view=diff&rev=567084&r1=567083&r2=567084
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchView.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchView.java
Fri Aug 17 09:47:11 2007
@@ -22,14 +22,20 @@
 
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
+import org.apache.directory.shared.ldap.schema.SchemaObject;
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.SearchViewController;
+import org.apache.directory.studio.apacheds.schemaeditor.view.search.SearchPage.SearchScopeEnum;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.graphics.Point;
@@ -62,32 +68,28 @@
     /** The view's ID */
     public static final String ID = Activator.PLUGIN_ID + ".view.SearchView"; //$NON-NLS-1$
 
-    // UI fields
-    private Table resultsTable;
-    private TableViewer resultsTableViewer;
-    private Text searchField;
+    private String searchString;
 
     /** The Type column */
     private final String TYPE_COLUMN = "Type";
-
     /** The Name column*/
     private final String NAME_COLUMN = "Name";
-
     /** The Schema column */
     private final String SCHEMA_COLUMN = "Schema";
 
-    /** The Search Field Composite */
+    // UI fields
+    private Text searchField;
+    private Label searchResultsLabel;
+    private Table resultsTable;
+    private TableViewer resultsTableViewer;
     private Composite searchFieldComposite;
-
-    /** The Search Field Inner Composite */
     private Composite searchFieldInnerComposite;
-
-    /** The separator */
     private Label separatorLabel;
-
     /** The parent composite */
     private Composite parent;
 
+    private Button searchButton;
+
 
     /* (non-Javadoc)
      * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
@@ -129,8 +131,7 @@
         searchFieldCompositeSeparator.setVisible( false );
 
         // Search Results Label
-        Label searchResultsLabel = new Label( parent, SWT.NONE );
-        searchResultsLabel.setText( "'searchString' - X matches in workspace" );
+        searchResultsLabel = new Label( parent, SWT.NONE );
         searchResultsLabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false )
);
 
         // Separator Label
@@ -138,7 +139,9 @@
         separatorLabel2.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
 
         // Create the table 
-        createTable();
+        createTableViewer();
+
+        setSearchResultsLabel( null, 0 );
 
         new SearchViewController( this );
     }
@@ -165,15 +168,24 @@
 
         // Search Text Field
         searchField = new Text( searchFieldInnerComposite, SWT.BORDER );
+        if ( searchString != null )
+        {
+            searchField.setText( searchString );
+        }
         searchField.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        searchField.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                validateSearchField();
+            }
+        } );
 
         // Search Scope Toolbar
         final ToolBar scopeToolBar = new ToolBar( searchFieldInnerComposite, SWT.HORIZONTAL
| SWT.FLAT );
         // Creating the Search Scope ToolItem
         final ToolItem scopeToolItem = new ToolItem( scopeToolBar, SWT.DROP_DOWN );
         scopeToolItem.setText( "Scope" );
-        // Creating the associated Menu
-        final Menu scopeMenu = new Menu( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
SWT.POP_UP );
         // Adding the action to display the Menu when the item is clicked
         scopeToolItem.addSelectionListener( new SelectionAdapter()
         {
@@ -182,48 +194,192 @@
                 Rectangle rect = scopeToolItem.getBounds();
                 Point pt = new Point( rect.x, rect.y + rect.height );
                 pt = scopeToolBar.toDisplay( pt );
-                scopeMenu.setLocation( pt.x, pt.y );
-                scopeMenu.setVisible( true );
+
+                Menu menu = createMenu();
+                menu.setLocation( pt.x, pt.y );
+                menu.setVisible( true );
             }
         } );
-        MenuItem aliasesMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+
+        // Search Button
+        searchButton = new Button( searchFieldInnerComposite, SWT.PUSH | SWT.DOWN );
+        searchButton.setEnabled( false );
+        searchButton.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_SEARCH ).createImage() );
+        searchButton.setToolTipText( "Search" );
+        searchButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                search();
+            }
+        } );
+
+        // Separator Label
+        separatorLabel = new Label( searchFieldComposite, SWT.SEPARATOR | SWT.HORIZONTAL
);
+        separatorLabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+    }
+
+
+    /**
+     * Creates the menu
+     *
+     * @return
+     *      the menu
+     */
+    public Menu createMenu()
+    {
+        final IDialogSettings settings = Activator.getDefault().getDialogSettings();
+
+        // Creating the associated Menu
+        Menu scopeMenu = new Menu( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
SWT.POP_UP );
+
+        // Filling the menu
+        // Aliases
+        final MenuItem aliasesMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
         aliasesMenuItem.setText( "Aliases" );
-        MenuItem oidMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        aliasesMenuItem.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_ALIASES, aliasesMenuItem.getSelection()
);
+            }
+        } );
+        // OID
+        final MenuItem oidMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
         oidMenuItem.setText( "OID" );
-        MenuItem descriptionMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        oidMenuItem.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_OID, oidMenuItem.getSelection()
);
+            }
+        } );
+        // Description
+        final MenuItem descriptionMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
         descriptionMenuItem.setText( "Description" );
+        descriptionMenuItem.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_DESCRIPTION, descriptionMenuItem.getSelection()
);
+            }
+        } );
+        // Separator
         new MenuItem( scopeMenu, SWT.SEPARATOR );
-        MenuItem superiorMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        // Superior
+        final MenuItem superiorMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
         superiorMenuItem.setText( "Superior" );
-        MenuItem syntaxMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        superiorMenuItem.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_SUPERIOR, superiorMenuItem.getSelection()
);
+            }
+        } );
+        // Syntax
+        final MenuItem syntaxMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
         syntaxMenuItem.setText( "Syntax" );
-        MenuItem matchingRulesMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        syntaxMenuItem.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_SYNTAX, syntaxMenuItem.getSelection()
);
+            }
+        } );
+        // Matching Rules
+        final MenuItem matchingRulesMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
         matchingRulesMenuItem.setText( "Matching Rules" );
+        matchingRulesMenuItem.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_MATCHING_RULES, matchingRulesMenuItem
+                    .getSelection() );
+            }
+        } );
+        // Separator
         new MenuItem( scopeMenu, SWT.SEPARATOR );
-        MenuItem superiorsMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        // Superiors
+        final MenuItem superiorsMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
         superiorsMenuItem.setText( "Superiors" );
-        MenuItem mandatoryAttributesMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        superiorsMenuItem.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_SUPERIORS, superiorsMenuItem.getSelection()
);
+            }
+        } );
+        // Mandatory Attributes
+        final MenuItem mandatoryAttributesMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
         mandatoryAttributesMenuItem.setText( "Mandatory Attributes" );
-        MenuItem optionalAttributesMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        mandatoryAttributesMenuItem.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_MANDATORY_ATTRIBUTES,
mandatoryAttributesMenuItem
+                    .getSelection() );
+            }
+        } );
+        // Optional Attributes
+        final MenuItem optionalAttributesMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
         optionalAttributesMenuItem.setText( "Optional Attributes" );
-        
+        optionalAttributesMenuItem.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_OPTIONAL_ATTRIBUTES,
optionalAttributesMenuItem
+                    .getSelection() );
+            }
+        } );
 
-        // Search Button
-        Button searchButton = new Button( searchFieldInnerComposite, SWT.PUSH | SWT.DOWN
);
-        searchButton.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
-            PluginConstants.IMG_SEARCH ).createImage() );
-        searchButton.setToolTipText( "Search" );
+        if ( settings.get( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_ALIASES ) == null )
+        {
+            aliasesMenuItem.setSelection( true );
+        }
+        else
+        {
+            aliasesMenuItem.setSelection( settings.getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_ALIASES
) );
+        }
 
-        // Separator Label
-        separatorLabel = new Label( searchFieldComposite, SWT.SEPARATOR | SWT.HORIZONTAL
);
-        separatorLabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        if ( settings.get( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_OID ) == null )
+        {
+            oidMenuItem.setSelection( true );
+        }
+        else
+        {
+
+            oidMenuItem.setSelection( settings.getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_OID
) );
+        }
+
+        if ( settings.get( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_DESCRIPTION ) == null
)
+        {
+            descriptionMenuItem.setSelection( true );
+        }
+        else
+        {
+            descriptionMenuItem
+                .setSelection( settings.getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_DESCRIPTION
) );
+        }
+
+        superiorMenuItem.setSelection( settings.getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_SUPERIOR
) );
+        syntaxMenuItem.setSelection( settings.getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_SYNTAX
) );
+        matchingRulesMenuItem.setSelection( settings
+            .getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_MATCHING_RULES ) );
+        superiorsMenuItem.setSelection( settings.getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_SUPERIORS
) );
+        mandatoryAttributesMenuItem.setSelection( settings
+            .getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_MANDATORY_ATTRIBUTES ) );
+        optionalAttributesMenuItem.setSelection( settings
+            .getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_OPTIONAL_ATTRIBUTES ) );
+
+        return scopeMenu;
     }
 
 
     /**
-     * Creates the Table.
+     * Creates the TableViewer.
      */
-    private void createTable()
+    private void createTableViewer()
     {
         resultsTable = new Table( parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION
             | SWT.HIDE_SELECTION );
@@ -251,9 +407,11 @@
 
         // Creating the TableViewer
         resultsTableViewer = new TableViewer( resultsTable );
-        resultsTableViewer.setUseHashlookup( true );
+        //        resultsTableViewer.setUseHashlookup( true );
         resultsTableViewer.setColumnProperties( new String[]
             { TYPE_COLUMN, NAME_COLUMN, SCHEMA_COLUMN } );
+        resultsTableViewer.setLabelProvider( new LabelProvider() );
+        resultsTableViewer.setContentProvider( new ArrayContentProvider() );
     }
 
 
@@ -382,15 +540,19 @@
     /* (non-Javadoc)
      * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
      */
-    @Override
     public void setFocus()
     {
         if ( searchField != null && !searchField.isDisposed() )
         {
             searchField.setFocus();
         }
+        else
+        {
+            resultsTable.setFocus();
+        }
     }
 
+
     /**
      * Shows the Search Field Section.
      */
@@ -399,6 +561,7 @@
         createSearchField();
         parent.layout( true, true );
         searchField.setFocus();
+        validateSearchField();
     }
 
 
@@ -419,5 +582,96 @@
         }
         parent.layout( true, true );
         resultsTable.setFocus();
+    }
+
+
+    private void validateSearchField()
+    {
+        searchButton.setEnabled( searchField.getText().length() > 0 );
+    }
+
+
+    /**
+     * Sets the Search Input.
+     *
+     * @param searchString
+     *      the search String
+     * @param scope
+     *      the search Scope
+     */
+    public void setSearchInput( String searchString, SearchScopeEnum[] scope )
+    {
+        this.searchString = searchString;
+        if ( ( searchField != null ) && ( !searchField.isDisposed() ) )
+        {
+            searchField.setText( searchString );
+            validateSearchField();
+        }
+        List<SchemaObject> results = search( searchString, scope );
+        setSearchResultsLabel( searchString, results.size() );
+    }
+
+
+    /**
+     * Searches the objects corresponding to the search parameters.
+     *
+     * @param searchString
+     *      the search String
+     * @param scope
+     *      the search Scope
+     */
+    private List<SchemaObject> search( String searchString, SearchScopeEnum[] scope
)
+    {
+        return new ArrayList<SchemaObject>();
+    }
+
+
+    /**
+     * Launches the search from the search fields views.
+     */
+    private void search()
+    {
+        // TODO
+    }
+
+
+    /**
+     * Refresh the overview label with the number of results.
+     *
+     * @param searchString
+     *      the search String
+     * @param resultsCount
+     *      the number of results
+     */
+    public void setSearchResultsLabel( String searchString, int resultsCount )
+    {
+        StringBuffer sb = new StringBuffer();
+
+        if ( searchString == null )
+        {
+            sb.append( "No search" );
+        }
+        else
+        {
+            // Search String
+            sb.append( "'" + searchString + "'" );
+            sb.append( " - " );
+
+            // Search results count
+            sb.append( resultsCount );
+            sb.append( " " );
+            if ( resultsCount > 1 )
+            {
+                sb.append( "matches" );
+            }
+            else
+            {
+                sb.append( "match" );
+            }
+
+            sb.append( " in workspace" );
+        }
+
+        searchResultsLabel.setText( sb.toString() );
     }
 }



Mime
View raw message