directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r562585 - in /directory/studio/trunk/studio-apacheds-schemaeditor: ./ META-INF/ resources/icons/ src/main/java/org/apache/directory/studio/apacheds/schemaeditor/ src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/act...
Date Fri, 03 Aug 2007 21:20:18 GMT
Author: pamarcelot
Date: Fri Aug  3 14:20:17 2007
New Revision: 562585

URL: http://svn.apache.org/viewvc?view=rev&rev=562585
Log:
Added Search Page and implementation for ShowSearchHistoryAction.

Added:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/search/
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/search/SearchPage.java
Modified:
    directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF
    directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml
    directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/search.gif
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginConstants.java
    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/views/SearchView.java

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF?view=diff&rev=562585&r1=562584&r2=562585
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF Fri Aug  3 14:20:17
2007
@@ -10,7 +10,8 @@
  org.eclipse.core.runtime,
  org.apache.directory.studio.jars,
  org.eclipse.jface.text,
- org.eclipse.ui.forms
+ org.eclipse.ui.forms,
+ org.eclipse.search
 Eclipse-LazyStart: true
 Bundle-ClassPath: .,
  lib/apacheds-core-plugin-1.5.0-SNAPSHOT.jar,

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml?view=diff&rev=562585&r1=562584&r2=562585
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml Fri Aug  3 14:20:17 2007
@@ -261,4 +261,15 @@
           </description>
        </decorator>
     </extension>
+	<extension
+         point="org.eclipse.search.searchPages">
+		<page
+			class="org.apache.directory.studio.apacheds.schemaeditor.view.search.SearchPage"
+            enabled="true"
+            icon="resources/icons/search.gif"
+            id="org.apache.directory.studio.apacheds.schemaeditor.search"
+            label="Schema Editor Search"
+            showScopeSection="false"
+            sizeHint="450,300"/>
+	</extension>
 </plugin>

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/search.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/search.gif?view=diff&rev=562585&r1=562584&r2=562585
==============================================================================
Binary files - no diff available.

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginConstants.java?view=diff&rev=562585&r1=562584&r2=562585
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginConstants.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginConstants.java
Fri Aug  3 14:20:17 2007
@@ -94,6 +94,7 @@
     public static final String IMG_SCHEMAS_IMPORT = "resources/icons/schemas_import.gif";
     public static final String IMG_SCHEMAS_IMPORT_WIZARD = "resources/icons/schemas_import_wizard.png";
     public static final String IMG_SEARCH = "resources/icons/search.gif";
+    public static final String IMG_SEARCH_HISTORY_ITEM = "resources/icons/search_history_item.gif";
     public static final String IMG_SHOW_SEARCH_FIELD = "resources/icons/show_search_field.gif";
     public static final String IMG_SHOW_SEARCH_HISTORY = "resources/icons/show_search_history.gif";
     public static final String IMG_SHOW_SUBTYPE_HIERARCHY = "resources/icons/hierarchy_subtype.gif";
@@ -228,4 +229,35 @@
     /** The preference ID for Hierarchy View Abbreviate Secondary Label Max Length*/
     public static final String PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH
= HierarchyViewPreferencePage.ID
         + ".secondaryLabel.abbreviate.maxLength"; //$NON-NLS-1$
+
+    // Preferences - Search View
+    /** The preference ID for Search History of the Search Page */
+    public static final String PREFS_SEARCH_PAGE_SEARCH_HISTORY = Activator.PLUGIN_ID
+        + ".preferences.SearchPage.searchHistory"; //$NON-NLS-1$
+    /** The preference ID for Search Scope 'Aliases' of the Search View */
+    public static final String PREFS_SEARCH_PAGE_SCOPE_ALIASES = Activator.PLUGIN_ID
+        + ".preferences.SearchPage.scopeAliases"; //$NON-NLS-1$
+    /** The preference ID for Search Scope 'OID' of the Search View */
+    public static final String PREFS_SEARCH_PAGE_SCOPE_OID = Activator.PLUGIN_ID + ".preferences.SearchPage.scopeOid";
//$NON-NLS-1$
+    /** The preference ID for Search Scope 'Description' of the Search View */
+    public static final String PREFS_SEARCH_PAGE_SCOPE_DESCRIPTION = Activator.PLUGIN_ID
+        + ".preferences.SearchPage.scopeDescription"; //$NON-NLS-1$
+    /** The preference ID for Search Scope 'Superior' of the Search View */
+    public static final String PREFS_SEARCH_PAGE_SCOPE_SUPERIOR = Activator.PLUGIN_ID
+        + ".preferences.SearchPage.scopeSuperior"; //$NON-NLS-1$
+    /** The preference ID for Search Scope 'Syntax' of the Search View */
+    public static final String PREFS_SEARCH_PAGE_SCOPE_SYNTAX = Activator.PLUGIN_ID
+        + ".preferences.SearchPage.scopeSyntax"; //$NON-NLS-1$
+    /** The preference ID for Search Scope 'Matching Rules' of the Search View */
+    public static final String PREFS_SEARCH_PAGE_SCOPE_MATCHING_RULES = Activator.PLUGIN_ID
+        + ".preferences.SearchPage.scopeMatchingRules"; //$NON-NLS-1$
+    /** The preference ID for Search Scope 'Superiors' of the Search View */
+    public static final String PREFS_SEARCH_PAGE_SCOPE_SUPERIORS = Activator.PLUGIN_ID
+        + ".preferences.SearchPage.scopeSuperiors"; //$NON-NLS-1$
+    /** The preference ID for Search Scope 'Mandatory Attributes' of the Search View */
+    public static final String PREFS_SEARCH_PAGE_SCOPE_MANDATORY_ATTRIBUTES = Activator.PLUGIN_ID
+        + ".preferences.SearchPage.scopeMandatoryAttributes"; //$NON-NLS-1$
+    /** The preference ID for Search Scope 'Optional Attributes' of the Search View */
+    public static final String PREFS_SEARCH_PAGE_SCOPE_OPTIONAL_ATTRIBUTES = Activator.PLUGIN_ID
+        + ".preferences.SearchPage.scopeOptionalAttributes"; //$NON-NLS-1$
 }

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=562585&r1=562584&r2=562585
==============================================================================
--- 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  3 14:20:17 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.search.SearchPage;
 import org.apache.directory.studio.apacheds.schemaeditor.view.views.SearchView;
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IAction;
@@ -33,7 +34,6 @@
 import org.eclipse.swt.widgets.MenuItem;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 
 
@@ -76,15 +76,6 @@
     }
 
 
-    @Override
-    public IMenuCreator getMenuCreator()
-    {
-        System.out.println( "getMenuCreator" );
-        // TODO Auto-generated method stub
-        return super.getMenuCreator();
-    }
-
-
     /* (non-Javadoc)
      * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
      */
@@ -147,13 +138,21 @@
     {
         menu = new Menu( parent );
 
-        MenuItem item = new MenuItem( menu, SWT.RADIO );
-        item.setText( "searchString1" );
-        item = new MenuItem( menu, SWT.RADIO );
-        item.setText( "searchString2" );
-        item.setSelection( true );
-        item = new MenuItem( menu, SWT.SEPARATOR );
-        item = new MenuItem( menu, SWT.PUSH );
+        String[] previousSearches = SearchPage.loadSearchStringHistory();
+        for ( String search : previousSearches )
+        {
+            MenuItem item = new MenuItem( menu, SWT.RADIO );
+            item.setText( search );
+            item.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                PluginConstants.IMG_SEARCH_HISTORY_ITEM ).createImage() );
+        }
+
+        if ( previousSearches.length > 0 )
+        {
+            new MenuItem( menu, SWT.SEPARATOR );
+        }
+        
+        MenuItem item = new MenuItem( menu, SWT.PUSH );
         item.setText( "History..." );
         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/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=auto&rev=562585
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/search/SearchPage.java
(added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/search/SearchPage.java
Fri Aug  3 14:20:17 2007
@@ -0,0 +1,397 @@
+/*
+ *  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.search;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.directory.studio.apacheds.schemaeditor.Activator;
+import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.search.ui.ISearchPage;
+import org.eclipse.search.ui.ISearchPageContainer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+
+
+/**
+ * This class implements the Search Page.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchPage extends DialogPage implements ISearchPage
+{
+    /** The SearchPageContainer */
+    private ISearchPageContainer container;
+
+    // UI Fields
+    private Combo searchCombo;
+    private Button aliasesButton;
+    private Button oidButton;
+    private Button descriptionButon;
+    private Button superiorButton;
+    private Button syntaxButton;
+    private Button matchingRulesButton;
+    private Button superiorsButton;
+    private Button mandatoryAttributes;
+    private Button optionalAttributes;
+
+    /**
+     * This enums represents the different possible scopes for a Schema Search.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
+    public enum SearchScopeEnum
+    {
+        ALIASES, OID, DESCRIPTION, SUPERIOR, SYNTAX, MATCHING_RULES, SUPERIORS, MANDATORY_ATTRIBUTES,
OPTIONAL_ATTRIBUTES
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+     */
+    public void createControl( Composite parent )
+    {
+        parent.setLayout( new GridLayout() );
+
+        // Search String Label
+        Label searchStringLabel = new Label( parent, SWT.NONE );
+        searchStringLabel.setText( "Search string (*=any string, ?=any character):" );
+        searchStringLabel.setLayoutData( new GridData( GridData.FILL, SWT.NONE, true, false
) );
+
+        // Search Combo
+        searchCombo = new Combo( parent, SWT.DROP_DOWN | SWT.BORDER );
+        searchCombo.setLayoutData( new GridData( GridData.FILL, SWT.NONE, true, false ) );
+        searchCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent arg0 )
+            {
+                validate();
+            }
+        } );
+
+        // Seach In Group
+        Group searchIn = new Group( parent, SWT.NONE );
+        searchIn.setLayout( new GridLayout() );
+        searchIn.setText( "Search in" );
+        searchIn.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Aliases Button
+        aliasesButton = new Button( searchIn, SWT.CHECK );
+        aliasesButton.setText( "Aliases" );
+
+        // OID Button
+        oidButton = new Button( searchIn, SWT.CHECK );
+        oidButton.setText( "OID" );
+
+        // Description Button
+        descriptionButon = new Button( searchIn, SWT.CHECK );
+        descriptionButon.setText( "Description" );
+
+        // Specific Scope Composite
+        Composite specificScopeComposite = new Composite( parent, SWT.NONE );
+        GridLayout specificScopeLayout = new GridLayout( 2, true );
+        specificScopeLayout.marginBottom = 0;
+        specificScopeLayout.marginHeight = 0;
+        specificScopeLayout.marginLeft = 0;
+        specificScopeLayout.marginRight = 0;
+        specificScopeLayout.marginTop = 0;
+        specificScopeLayout.marginWidth = 0;
+        specificScopeComposite.setLayout( specificScopeLayout );
+        specificScopeComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false,
3, 1 ) );
+
+        // Attribute Types Group
+        Group attributeTypesGroup = new Group( specificScopeComposite, SWT.NONE );
+        attributeTypesGroup.setText( "Seach in (for attribute types)" );
+        attributeTypesGroup.setLayout( new GridLayout() );
+        attributeTypesGroup.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true )
);
+
+        // Superior Button
+        superiorButton = new Button( attributeTypesGroup, SWT.CHECK );
+        superiorButton.setText( "Superior" );
+
+        // Syntax Button
+        syntaxButton = new Button( attributeTypesGroup, SWT.CHECK );
+        syntaxButton.setText( "Syntax" );
+
+        // Matching Rules Button
+        matchingRulesButton = new Button( attributeTypesGroup, SWT.CHECK );
+        matchingRulesButton.setText( "Matching Rules" );
+
+        // Object Classes Group
+        Group objectClassesGroup = new Group( specificScopeComposite, SWT.NONE );
+        objectClassesGroup.setText( "Search in (for object classes)" );
+        objectClassesGroup.setLayout( new GridLayout() );
+        objectClassesGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false )
);
+
+        // Superiors Button
+        superiorsButton = new Button( objectClassesGroup, SWT.CHECK );
+        superiorsButton.setText( "Superiors" );
+
+        // Mandatory Attributes Button
+        mandatoryAttributes = new Button( objectClassesGroup, SWT.CHECK );
+        mandatoryAttributes.setText( "Mandatory Attributes" );
+
+        // Optional Attributes Button
+        optionalAttributes = new Button( objectClassesGroup, SWT.CHECK );
+        optionalAttributes.setText( "Optional Attributes" );
+
+        initSearchStringHistory();
+
+        initSearchScope();
+
+        super.setControl( parent );
+    }
+
+
+    /**
+     * Initializes the Search String History.
+     */
+    private void initSearchStringHistory()
+    {
+        searchCombo.setItems( loadSearchStringHistory() );
+    }
+
+
+    /**
+     * Initializes the Search Scope
+     */
+    private void initSearchScope()
+    {
+        IDialogSettings settings = Activator.getDefault().getDialogSettings();
+
+        if ( settings.get( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_ALIASES ) == null )
+        {
+            aliasesButton.setSelection( true );
+        }
+        else
+        {
+            aliasesButton.setSelection( settings.getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_ALIASES
) );
+        }
+
+        if ( settings.get( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_OID ) == null )
+        {
+            oidButton.setSelection( true );
+        }
+        else
+        {
+            oidButton.setSelection( settings.getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_OID
) );
+        }
+
+        if ( settings.get( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_DESCRIPTION ) == null
)
+        {
+            descriptionButon.setSelection( true );
+        }
+        else
+        {
+            descriptionButon.setSelection( settings.getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_DESCRIPTION
) );
+        }
+        superiorButton.setSelection( settings.getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_SUPERIOR
) );
+        syntaxButton.setSelection( settings.getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_SYNTAX
) );
+        matchingRulesButton
+            .setSelection( settings.getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_MATCHING_RULES
) );
+        superiorsButton.setSelection( settings.getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_SUPERIORS
) );
+        mandatoryAttributes.setSelection( settings
+            .getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_MANDATORY_ATTRIBUTES ) );
+        optionalAttributes.setSelection( settings
+            .getBoolean( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_OPTIONAL_ATTRIBUTES ) );
+
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.search.ui.ISearchPage#performAction()
+     */
+    public boolean performAction()
+    {
+        List<SearchScopeEnum> searchScope = new ArrayList<SearchScopeEnum>();
+        if ( aliasesButton.getSelection() )
+        {
+            searchScope.add( SearchScopeEnum.ALIASES );
+        }
+        if ( oidButton.getSelection() )
+        {
+            searchScope.add( SearchScopeEnum.OID );
+        }
+        if ( descriptionButon.getSelection() )
+        {
+            searchScope.add( SearchScopeEnum.DESCRIPTION );
+        }
+        if ( superiorButton.getSelection() )
+        {
+            searchScope.add( SearchScopeEnum.SUPERIOR );
+        }
+        if ( syntaxButton.getSelection() )
+        {
+            searchScope.add( SearchScopeEnum.SYNTAX );
+        }
+        if ( matchingRulesButton.getSelection() )
+        {
+            searchScope.add( SearchScopeEnum.MATCHING_RULES );
+        }
+        if ( superiorsButton.getSelection() )
+        {
+            searchScope.add( SearchScopeEnum.SUPERIORS );
+        }
+        if ( mandatoryAttributes.getSelection() )
+        {
+            searchScope.add( SearchScopeEnum.MANDATORY_ATTRIBUTES );
+        }
+        if ( optionalAttributes.getSelection() )
+        {
+            searchScope.add( SearchScopeEnum.OPTIONAL_ATTRIBUTES );
+        }
+
+        //
+        //        searchView.setSearch( searchCombo.getText(), scope );
+
+        saveSearchScope( searchScope );
+        addSearchStringHistory( searchCombo.getText() );
+
+        return true;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.search.ui.ISearchPage#setContainer(org.eclipse.search.ui.ISearchPageContainer)
+     */
+    public void setContainer( ISearchPageContainer container )
+    {
+        this.container = container;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
+     */
+    public void setVisible( boolean visible )
+    {
+        validate();
+        super.setVisible( visible );
+    }
+
+
+    /**
+     * Verifies if the page is valid.
+     *
+     * @return
+     *      true if the page is valid
+     */
+    private boolean isValid()
+    {
+        return ( ( searchCombo.getText() != null ) && ( !"".equals( searchCombo.getText()
) ) ); //$NON-NLS-1$
+    }
+
+
+    /**
+     * Validates the page.
+     */
+    private void validate()
+    {
+        container.setPerformActionEnabled( isValid() );
+    }
+
+
+    /**
+     * Saves to the History.
+     *
+     * @param value
+     *      the value to save
+     */
+    public static void addSearchStringHistory( String value )
+    {
+        // get current history
+        String[] history = loadSearchStringHistory();
+        List<String> list = new ArrayList<String>( Arrays.asList( history ) );
+
+        // add new value or move to first position
+        if ( list.contains( value ) )
+        {
+            list.remove( value );
+        }
+        list.add( 0, value );
+
+        // check history size
+        while ( list.size() > 10 )
+        {
+            list.remove( list.size() - 1 );
+        }
+
+        // save
+        history = ( String[] ) list.toArray( new String[list.size()] );
+        Activator.getDefault().getDialogSettings().put( PluginConstants.PREFS_SEARCH_PAGE_SEARCH_HISTORY,
history );
+    }
+
+
+    /**
+     * Loads the Search History
+     *
+     * @return
+     *      an array of String containing the Search History
+     */
+    public static String[] loadSearchStringHistory()
+    {
+        String[] history = Activator.getDefault().getDialogSettings().getArray(
+            PluginConstants.PREFS_SEARCH_PAGE_SEARCH_HISTORY );
+        if ( history == null )
+        {
+            history = new String[0];
+        }
+        return history;
+    }
+
+
+    public static void saveSearchScope( List<SearchScopeEnum> scope )
+    {
+        if ( ( scope != null ) && ( scope.size() > 0 ) )
+        {
+            IDialogSettings settings = Activator.getDefault().getDialogSettings();
+
+            settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_ALIASES, scope.contains(
SearchScopeEnum.ALIASES ) );
+            settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_OID, scope.contains( SearchScopeEnum.OID
) );
+            settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_DESCRIPTION, scope
+                .contains( SearchScopeEnum.DESCRIPTION ) );
+            settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_SUPERIOR, scope.contains(
SearchScopeEnum.SUPERIOR ) );
+            settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_SYNTAX, scope.contains(
SearchScopeEnum.SYNTAX ) );
+            settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_MATCHING_RULES, scope
+                .contains( SearchScopeEnum.MATCHING_RULES ) );
+            settings
+                .put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_SUPERIORS, scope.contains(
SearchScopeEnum.SUPERIORS ) );
+            settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_MANDATORY_ATTRIBUTES, scope
+                .contains( SearchScopeEnum.MANDATORY_ATTRIBUTES ) );
+            settings.put( PluginConstants.PREFS_SEARCH_PAGE_SCOPE_OPTIONAL_ATTRIBUTES, scope
+                .contains( SearchScopeEnum.OPTIONAL_ATTRIBUTES ) );
+        }
+    }
+}

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=562585&r1=562584&r2=562585
==============================================================================
--- 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  3 14:20:17 2007
@@ -21,6 +21,10 @@
 package org.apache.directory.studio.apacheds.schemaeditor.view.views;
 
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
 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;
@@ -33,7 +37,6 @@
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Menu;
@@ -63,8 +66,6 @@
     private Table resultsTable;
     private TableViewer resultsTableViewer;
     private Text searchField;
-    private Combo scopeCombo;
-    //    private SearchViewContentProvider searchContentProvider;
 
     /** The Type column */
     private final String TYPE_COLUMN = "Type";
@@ -75,36 +76,18 @@
     /** The Schema column */
     private final String SCHEMA_COLUMN = "Schema";
 
-    /** The Columns names Array */
-    private String[] columnNames = new String[]
-        { TYPE_COLUMN, NAME_COLUMN, SCHEMA_COLUMN, };
+    /** The Search Field Composite */
+    private Composite searchFieldComposite;
 
+    /** The Search Field Inner Composite */
     private Composite searchFieldInnerComposite;
 
+    /** The separator */
     private Label separatorLabel;
 
+    /** The parent composite */
     private Composite parent;
 
-    private Composite searchFieldComposite;
-
-    /** The scope */
-    public static final String SCOPE = "Scope";
-
-    /** The Search All scope */
-    public static final String SEARCH_ALL = "All Metadata";
-
-    /** The Search Name scope */
-    public static final String SEARCH_NAME = "Name";
-
-    /** The Search OID scope */
-    public static final String SEARCH_OID = "OID";
-
-    /** The Search Description scope */
-    public static final String SEARCH_DESC = "Description";
-
-    /** The current Search type */
-    public static String currentSearchScope = SEARCH_ALL;
-
 
     /* (non-Javadoc)
      * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
@@ -157,15 +140,6 @@
         // Create the table 
         createTable();
 
-        //        this.searchContentProvider = new SearchViewContentProvider();
-        //        resultsTableViewer.setContentProvider( searchContentProvider );
-        //        resultsTableViewer.setLabelProvider( new TableDecoratingLabelProvider(
new SearchViewLabelProvider(), Activator
-        //            .getDefault().getWorkbench().getDecoratorManager().getLabelDecorator()
) );
-
-        //        initSearchHistory();
-        //        initListeners();
-        //        initToolbar();
-
         new SearchViewController( this );
     }
 
@@ -212,9 +186,27 @@
                 scopeMenu.setVisible( true );
             }
         } );
-        MenuItem item = new MenuItem( scopeMenu, SWT.CHECK );
-        item.setSelection( true );
-        item.setText( "Aliases" );
+        MenuItem aliasesMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        aliasesMenuItem.setText( "Aliases" );
+        MenuItem oidMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        oidMenuItem.setText( "OID" );
+        MenuItem descriptionMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        descriptionMenuItem.setText( "Description" );
+        new MenuItem( scopeMenu, SWT.SEPARATOR );
+        MenuItem superiorMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        superiorMenuItem.setText( "Superior" );
+        MenuItem syntaxMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        syntaxMenuItem.setText( "Syntax" );
+        MenuItem matchingRulesMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        matchingRulesMenuItem.setText( "Matching Rules" );
+        new MenuItem( scopeMenu, SWT.SEPARATOR );
+        MenuItem superiorsMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        superiorsMenuItem.setText( "Superiors" );
+        MenuItem mandatoryAttributesMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        mandatoryAttributesMenuItem.setText( "Mandatory Attributes" );
+        MenuItem optionalAttributesMenuItem = new MenuItem( scopeMenu, SWT.CHECK );
+        optionalAttributesMenuItem.setText( "Optional Attributes" );
+        
 
         // Search Button
         Button searchButton = new Button( searchFieldInnerComposite, SWT.PUSH | SWT.DOWN
);
@@ -244,23 +236,24 @@
 
         // 1st column with image
         TableColumn column = new TableColumn( resultsTable, SWT.CENTER, 0 );
-        column.setText( columnNames[0] );
+        column.setText( TYPE_COLUMN );
         column.setWidth( 40 );
 
         // 2nd column with name
         column = new TableColumn( resultsTable, SWT.LEFT, 1 );
-        column.setText( columnNames[1] );
+        column.setText( NAME_COLUMN );
         column.setWidth( 400 );
 
         // 3rd column with element defining schema
         column = new TableColumn( resultsTable, SWT.LEFT, 2 );
-        column.setText( columnNames[2] );
+        column.setText( SCHEMA_COLUMN );
         column.setWidth( 100 );
 
         // Creating the TableViewer
         resultsTableViewer = new TableViewer( resultsTable );
         resultsTableViewer.setUseHashlookup( true );
-        resultsTableViewer.setColumnProperties( columnNames );
+        resultsTableViewer.setColumnProperties( new String[]
+            { TYPE_COLUMN, NAME_COLUMN, SCHEMA_COLUMN } );
     }
 
 
@@ -397,85 +390,6 @@
             searchField.setFocus();
         }
     }
-
-
-    //    /* (non-Javadoc)
-    //     * @see org.eclipse.ui.part.ViewPart#setPartName(java.lang.String)
-    //     */
-    //    public void setPartName( String partName )
-    //    {
-    //        super.setPartName( partName );
-    //    }
-
-    //    /**
-    //     * Initializes the Search History.
-    //     */
-    //    private void initSearchHistory()
-    //    {
-    //        searchField.setItems( loadHistory( PluginConstants.PREFS_SEARCH_VIEW_SEARCH_HISTORY
) );
-    //    }
-    //
-    //
-    //    /**
-    //     * Saves to the History.
-    //     *
-    //     * @param key
-    //     *      the key to save to
-    //     * @param value
-    //     *      the value to save
-    //     */
-    //    public static void saveHistory( String key, String value )
-    //    {
-    //        // get current history
-    //        String[] history = loadHistory( key );
-    //        List<String> list = new ArrayList<String>( Arrays.asList( history
) );
-    //
-    //        // add new value or move to first position
-    //        if ( list.contains( value ) )
-    //        {
-    //            list.remove( value );
-    //        }
-    //        list.add( 0, value );
-    //
-    //        // check history size
-    //        while ( list.size() > 15 )
-    //        {
-    //            list.remove( list.size() - 1 );
-    //        }
-    //
-    //        // save
-    //        history = ( String[] ) list.toArray( new String[list.size()] );
-    //        Activator.getDefault().getDialogSettings().put( key, history );
-    //
-    //    }
-    //
-    //
-    //    /**
-    //     * Loads History
-    //     *
-    //     * @param key
-    //     *      the preference key
-    //     * @return
-    //     */
-    //    public static String[] loadHistory( String key )
-    //    {
-    //        String[] history = Activator.getDefault().getDialogSettings().getArray( key
);
-    //        if ( history == null )
-    //        {
-    //            history = new String[0];
-    //        }
-    //        return history;
-    //    }
-    //
-    //
-    //    public void setSearch( String searchString, String scope )
-    //    {
-    //        scopeCombo.setText( scope );
-    //        currentSearchScope = scopeCombo.getText();
-    //        searchField.setText( searchString );
-    //        resultsTableViewer.setInput( searchString );
-    //        resultsTable.setFocus();
-    //    }
 
     /**
      * Shows the Search Field Section.



Mime
View raw message