directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r562155 - in /directory/studio/trunk/studio-apacheds-schemaeditor: ./ resources/icons/ src/main/java/org/apache/directory/studio/apacheds/schemaeditor/ src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/ src/main/jav...
Date Thu, 02 Aug 2007 15:54:51 GMT
Author: pamarcelot
Date: Thu Aug  2 08:54:50 2007
New Revision: 562155

URL: http://svn.apache.org/viewvc?view=rev&rev=562155
Log:
Added the SearchView and the ShowSearchFieldAction.

Added:
    directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/search_view.gif  
(with props)
    directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/show_search_field.gif
  (with props)
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SearchViewController.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/ShowSearchFieldAction.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/plugin.xml
    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/view/Perspective.java

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=562155&r1=562154&r2=562155
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml Thu Aug  2 08:54:50 2007
@@ -60,6 +60,13 @@
             icon="resources/icons/projects_view.gif"
             id="org.apache.directory.studio.apacheds.schemaeditor.view.ProjectsView"
             name="Projects"/>
+	<view
+            allowMultiple="false"
+            category="org.apache.directory.studio.apacheds.schemaeditor.view.category"
+            class="org.apache.directory.studio.apacheds.schemaeditor.view.views.SearchView"
+            icon="resources/icons/search_view.gif"
+            id="org.apache.directory.studio.apacheds.schemaeditor.view.SearchView"
+            name="Search"/>
    </extension>
  <extension
        point="org.eclipse.core.runtime.preferences">

Added: directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/search_view.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/search_view.gif?view=auto&rev=562155
==============================================================================
Binary file - no diff available.

Propchange: directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/search_view.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/show_search_field.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/show_search_field.gif?view=auto&rev=562155
==============================================================================
Binary file - no diff available.

Propchange: directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/show_search_field.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

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=562155&r1=562154&r2=562155
==============================================================================
--- 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
Thu Aug  2 08:54:50 2007
@@ -92,6 +92,7 @@
     public static final String IMG_SCHEMAS_EXPORT_WIZARD = "resources/icons/schemas_export_wizard.png";
     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_SHOW_SEARCH_FIELD = "resources/icons/show_search_field.gif";
     public static final String IMG_SHOW_SUBTYPE_HIERARCHY = "resources/icons/hierarchy_subtype.gif";
     public static final String IMG_SHOW_SUPERTYPE_HIERARCHY = "resources/icons/hierarchy_supertype.gif";
     public static final String IMG_SORTING = "resources/icons/sorting.gif";
@@ -131,6 +132,7 @@
     public static final String CMD_NEW_PROJECT = Activator.PLUGIN_ID + ".commands.newProject";
     public static final String CMD_NEW_SCHEMA = Activator.PLUGIN_ID + ".commands.newSchema";
     public static final String CMD_RENAME_PROJECT = Activator.PLUGIN_ID + ".commands.renameProject";
+    public static final String CMD_SHOW_SEARCH_FIELD = Activator.PLUGIN_ID + ".commands.showSearchField";
     public static final String CMD_SHOW_SUBTYPE_HIERARCHY = Activator.PLUGIN_ID + ".commands.showSubTypeHierarchy";
     public static final String CMD_SHOW_SUPERTYPE_HIERARCHY = Activator.PLUGIN_ID + ".commands.showSuperTypeHierarchy";
 

Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SearchViewController.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SearchViewController.java?view=auto&rev=562155
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SearchViewController.java
(added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SearchViewController.java
Thu Aug  2 08:54:50 2007
@@ -0,0 +1,138 @@
+/*
+ *  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.controller;
+
+
+import java.util.ArrayList;
+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.actions.CollapseAllAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ConnectAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.DeleteSchemaElementAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ExportSchemasAsOpenLdapAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ExportSchemasAsXmlAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ExportSchemasForADSAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ImportSchemasFromOpenLdapAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ImportSchemasFromXmlAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.LinkWithEditorSchemaViewAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.NewAttributeTypeAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.NewObjectClassAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.NewSchemaAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.OpenElementAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.OpenSchemaViewPreferenceAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.OpenSchemaViewSortingDialogAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.OpenTypeHierarchyAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ShowSearchFieldAction;
+import org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Project;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
+import org.apache.directory.studio.apacheds.schemaeditor.view.editors.attributetype.AttributeTypeEditor;
+import org.apache.directory.studio.apacheds.schemaeditor.view.editors.attributetype.AttributeTypeEditorInput;
+import org.apache.directory.studio.apacheds.schemaeditor.view.editors.objectclass.ObjectClassEditor;
+import org.apache.directory.studio.apacheds.schemaeditor.view.editors.objectclass.ObjectClassEditorInput;
+import org.apache.directory.studio.apacheds.schemaeditor.view.views.SchemaView;
+import org.apache.directory.studio.apacheds.schemaeditor.view.views.SearchView;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.AttributeTypeWrapper;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.Folder;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.ObjectClassWrapper;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.SchemaWrapper;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.TreeNode;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.Folder.FolderType;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * This class implements the Controller for the SearchView.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchViewController
+{
+    /** The associated view */
+    private SearchView view;
+
+    // The Actions
+    private ShowSearchFieldAction showSearchField;
+
+
+    /**
+     * Creates a new instance of SearchViewController.
+     *
+     * @param view
+     *      the associated view
+     */
+    public SearchViewController( SearchView view )
+    {
+        this.view = view;
+
+        initActions();
+        initToolbar();
+        initMenu();
+    }
+
+
+    /**
+     * Initializes the Actions.
+     */
+    private void initActions()
+    {
+        showSearchField = new ShowSearchFieldAction( view );
+    }
+
+
+    /**
+     * Initializes the Toolbar.
+     */
+    private void initToolbar()
+    {
+        IToolBarManager toolbar = view.getViewSite().getActionBars().getToolBarManager();
+        toolbar.add( showSearchField );
+    }
+
+
+    /**
+     * Initializes the Menu.
+     */
+    private void initMenu()
+    {
+        IMenuManager menu = view.getViewSite().getActionBars().getMenuManager();
+    }
+}

Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/ShowSearchFieldAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/ShowSearchFieldAction.java?view=auto&rev=562155
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/ShowSearchFieldAction.java
(added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/ShowSearchFieldAction.java
Thu Aug  2 08:54:50 2007
@@ -0,0 +1,137 @@
+/*
+ *  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.controller.actions;
+
+
+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.SearchView;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This action is used to link the with the view with the frontmost editor.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ShowSearchFieldAction extends Action implements IWorkbenchWindowActionDelegate
+{
+    /** The String for storing the checked state of the action */
+    private static final String SHOW_SEARCH_FIELD_DS_KEY = ShowSearchFieldAction.class.getName()
+ ".dialogsettingkey"; //$NON-NLS-1$
+
+    /** The associated view */
+    private SearchView view;
+
+
+    /**
+     * Creates a new instance of ShowSearchFieldAction.
+     */
+    public ShowSearchFieldAction( SearchView view )
+    {
+        super( "Show Search Field", AS_CHECK_BOX );
+        setToolTipText( getText() );
+        setId( PluginConstants.CMD_SHOW_SEARCH_FIELD );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_SHOW_SEARCH_FIELD ) );
+        setEnabled( true );
+        this.view = view;
+
+        // Setting up the default key value (if needed)
+        if ( Activator.getDefault().getDialogSettings().get( SHOW_SEARCH_FIELD_DS_KEY ) ==
null )
+        {
+            Activator.getDefault().getDialogSettings().put( SHOW_SEARCH_FIELD_DS_KEY, false
);
+        }
+
+        // Setting state from the dialog settings
+        setChecked( Activator.getDefault().getDialogSettings().getBoolean( SHOW_SEARCH_FIELD_DS_KEY
) );
+
+        if ( isChecked() )
+        {
+            view.showSearchFieldSection();
+        }
+        else
+        {
+            view.hideSearchFieldSection();
+        }
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.jface.action.Action#run()
+     */
+    public void run()
+    {
+        setChecked( isChecked() );
+        Activator.getDefault().getDialogSettings().put( SHOW_SEARCH_FIELD_DS_KEY, isChecked()
);
+
+        if ( isChecked() )
+        {
+            view.showSearchFieldSection();
+        }
+        else
+        {
+            view.hideSearchFieldSection();
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+     */
+    public void run( IAction action )
+    {
+        run();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+     */
+    public void dispose()
+    {
+        // Nothing to do
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+     */
+    public void init( IWorkbenchWindow window )
+    {
+        // Nothing to do
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
org.eclipse.jface.viewers.ISelection)
+     */
+    public void selectionChanged( IAction action, ISelection selection )
+    {
+        // Nothing to do
+    }
+}

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/Perspective.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/Perspective.java?view=diff&rev=562155&r1=562154&r2=562155
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/Perspective.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/Perspective.java
Thu Aug  2 08:54:50 2007
@@ -25,6 +25,7 @@
 import org.apache.directory.studio.apacheds.schemaeditor.view.views.ProblemsView;
 import org.apache.directory.studio.apacheds.schemaeditor.view.views.ProjectsView;
 import org.apache.directory.studio.apacheds.schemaeditor.view.views.SchemaView;
+import org.apache.directory.studio.apacheds.schemaeditor.view.views.SearchView;
 import org.apache.directory.studio.apacheds.schemaeditor.view.wizards.NewAttributeTypeWizard;
 import org.apache.directory.studio.apacheds.schemaeditor.view.wizards.NewObjectClassWizard;
 import org.apache.directory.studio.apacheds.schemaeditor.view.wizards.NewProjectWizard;
@@ -50,6 +51,9 @@
     /** The ID of the top left folder */
     public static final String topLeftFolderId = "org.apache.directory.studio.apacheds.schemaeditor.topleftfolder";
//$NON-NLS-1$
 
+    /** The ID of the bottom folder */
+    public static final String bottomFolderId = "org.apache.directory.studio.apacheds.schemaeditor.bottomfolder";
//$NON-NLS-1$
+
 
     /* (non-Javadoc)
      * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
@@ -62,13 +66,16 @@
 
         // Creating top left folder 
         IFolderLayout topLeftFolder = layout.createFolder( topLeftFolderId, IPageLayout.LEFT,
0.3f, editorAreaId );
-        layout.addPlaceholder( topLeftFolderId, IPageLayout.LEFT, 0.3f, editorAreaId );
+
+        // Creating bottom folder 
+        IFolderLayout bottomFolder = layout.createFolder( bottomFolderId, IPageLayout.BOTTOM,
0.7f, editorAreaId );
 
         // Adding Views
         topLeftFolder.addView( SchemaView.ID );
         topLeftFolder.addView( HierarchyView.ID );
         layout.addStandaloneView( ProjectsView.ID, true, IPageLayout.BOTTOM, 0.7f, topLeftFolderId
);
-        layout.addStandaloneView( ProblemsView.ID, true, IPageLayout.BOTTOM, 0.7f, editorAreaId
);
+        bottomFolder.addView( ProblemsView.ID );
+        bottomFolder.addView( SearchView.ID );
 
         // Setting up non-closeable views
         layout.getViewLayout( SchemaView.ID ).setCloseable( false );
@@ -83,6 +90,7 @@
         layout.addShowViewShortcut( ProjectsView.ID );
         layout.addShowViewShortcut( ProblemsView.ID );
         layout.addShowViewShortcut( HierarchyView.ID );
+        layout.addShowViewShortcut( SearchView.ID );
 
         // Adding New Wizard shortcuts
         layout.addNewWizardShortcut( NewProjectWizard.ID );

Added: 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=auto&rev=562155
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchView.java
(added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchView.java
Thu Aug  2 08:54:50 2007
@@ -0,0 +1,471 @@
+/*
+ *  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.views;
+
+
+import org.apache.directory.studio.apacheds.schemaeditor.Activator;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.SearchViewController;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.part.ViewPart;
+
+
+/**
+ * This class represents the Search View.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchView extends ViewPart
+{
+    /** 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 Combo scopeCombo;
+    //    private SearchViewContentProvider searchContentProvider;
+
+    /** 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 Columns names Array */
+    private String[] columnNames = new String[]
+        { TYPE_COLUMN, NAME_COLUMN, SCHEMA_COLUMN, };
+
+    private Composite searchFieldInnerComposite;
+
+    private Label separatorLabel;
+
+    private Composite parent;
+
+    private Composite searchFieldComposite;
+
+    /** 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)
+     */
+    @Override
+    public void createPartControl( Composite parent )
+    {
+        this.parent = parent;
+        GridLayout gridLayout = new GridLayout();
+        gridLayout.horizontalSpacing = 0;
+        gridLayout.marginBottom = 0;
+        gridLayout.marginHeight = 0;
+        gridLayout.marginLeft = 0;
+        gridLayout.marginRight = 0;
+        gridLayout.marginTop = 0;
+        gridLayout.marginWidth = 0;
+        gridLayout.verticalSpacing = 0;
+        parent.setLayout( gridLayout );
+
+        // Search Field
+        searchFieldComposite = new Composite( parent, SWT.NONE );
+        gridLayout = new GridLayout();
+        gridLayout.horizontalSpacing = 0;
+        gridLayout.marginBottom = 0;
+        gridLayout.marginHeight = 0;
+        gridLayout.marginLeft = 0;
+        gridLayout.marginRight = 0;
+        gridLayout.marginTop = 0;
+        gridLayout.marginWidth = 0;
+        gridLayout.verticalSpacing = 0;
+        searchFieldComposite.setLayout( gridLayout );
+        searchFieldComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false
) );
+
+        // Search Results Label
+        Label searchResultsLabel = new Label( parent, SWT.NONE );
+        searchResultsLabel.setText( "'searchString' - X matches in Schema" );
+        searchResultsLabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false )
);
+
+        // Separator Label
+        Label separatorLabel2 = new Label( parent, SWT.SEPARATOR | SWT.HORIZONTAL );
+        separatorLabel2.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // 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 );
+    }
+
+
+    /**
+     * Create the Search Field Sections.
+     */
+    private void createSearchField()
+    {
+        searchFieldInnerComposite = new Composite( searchFieldComposite, SWT.NONE );
+        GridLayout searchFieldInnerCompositeGridLayout = new GridLayout( 4, false );
+        searchFieldInnerCompositeGridLayout.horizontalSpacing = 3;
+        searchFieldInnerCompositeGridLayout.verticalSpacing = 3;
+        searchFieldInnerComposite.setLayout( searchFieldInnerCompositeGridLayout );
+        searchFieldInnerComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true,
false ) );
+
+        Label searchFieldLabel = new Label( searchFieldInnerComposite, SWT.NONE );
+        searchFieldLabel.setText( "Search:" );
+
+        searchField = new Text( searchFieldInnerComposite, SWT.DROP_DOWN | SWT.BORDER );
+        searchField.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        Label inLabel = new Label( searchFieldInnerComposite, SWT.NONE );
+        inLabel.setText( "Scope:" );
+
+        scopeCombo = new Combo( searchFieldInnerComposite, SWT.READ_ONLY | SWT.SINGLE );
+        scopeCombo.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                currentSearchScope = scopeCombo.getText();
+                resultsTableViewer.refresh();
+            }
+        } );
+        scopeCombo.add( SEARCH_ALL, 0 );
+        scopeCombo.add( SEARCH_NAME, 1 );
+        scopeCombo.add( SEARCH_OID, 2 );
+        scopeCombo.add( SEARCH_DESC, 3 );
+        scopeCombo.select( 0 );
+
+        // Separator Label
+        separatorLabel = new Label( searchFieldComposite, SWT.SEPARATOR | SWT.HORIZONTAL
);
+        separatorLabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+    }
+
+
+    /**
+     * Creates the Table.
+     */
+    private void createTable()
+    {
+        resultsTable = new Table( parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION
+            | SWT.HIDE_SELECTION );
+
+        GridData gridData = new GridData( SWT.FILL, SWT.FILL, true, true );
+        resultsTable.setLayoutData( gridData );
+
+        resultsTable.setLinesVisible( false );
+        resultsTable.setHeaderVisible( true );
+
+        // 1st column with image
+        TableColumn column = new TableColumn( resultsTable, SWT.CENTER, 0 );
+        column.setText( columnNames[0] );
+        column.setWidth( 40 );
+
+        // 2nd column with name
+        column = new TableColumn( resultsTable, SWT.LEFT, 1 );
+        column.setText( columnNames[1] );
+        column.setWidth( 400 );
+
+        // 3rd column with element defining schema
+        column = new TableColumn( resultsTable, SWT.LEFT, 2 );
+        column.setText( columnNames[2] );
+        column.setWidth( 100 );
+
+        // Creating the TableViewer
+        resultsTableViewer = new TableViewer( resultsTable );
+        resultsTableViewer.setUseHashlookup( true );
+        resultsTableViewer.setColumnProperties( columnNames );
+    }
+
+
+    //    /**
+    //     * Initializes the Listeners
+    //     */
+    //    private void initListeners()
+    //    {
+    //        searchField.addModifyListener( new ModifyListener()
+    //        {
+    //            public void modifyText( ModifyEvent e )
+    //            {
+    //                resultsTableViewer.setInput( searchField.getText() );
+    //            }
+    //        } );
+    //
+    //        searchField.addKeyListener( new KeyAdapter()
+    //        {
+    //            public void keyReleased( KeyEvent e )
+    //            {
+    //                if ( e.keyCode == 13 )
+    //                {
+    //                    resultsTable.setFocus();
+    //                }
+    //            }
+    //        } );
+    //
+    //        searchField.addFocusListener( new FocusAdapter()
+    //        {
+    //            public void focusLost( FocusEvent e )
+    //            {
+    //                if ( !"".equals( searchField.getText() ) ) //$NON-NLS-1$
+    //                {
+    //                    String searchString = searchField.getText();
+    //                    saveHistory( PluginConstants.PREFS_SEARCH_VIEW_SEARCH_HISTORY,
searchString );
+    //                    initSearchHistory();
+    //                    searchField.setText( searchString );
+    //                }
+    //            }
+    //        } );
+    //
+    //        scopeCombo.addFocusListener( new FocusAdapter()
+    //        {
+    //            public void focusGained( FocusEvent arg0 )
+    //            {
+    //                resultsTable.setFocus();
+    //            }
+    //        } );
+    //
+    //        resultsTable.addMouseListener( new MouseAdapter()
+    //        {
+    //            public void mouseDoubleClick( MouseEvent e )
+    //            {
+    //                openEditor( ( Table ) e.getSource() );
+    //            }
+    //        } );
+    //
+    //        resultsTable.addKeyListener( new KeyAdapter()
+    //        {
+    //            public void keyPressed( KeyEvent e )
+    //            {
+    //                if ( e.keyCode == SWT.ARROW_UP )
+    //                {
+    //                    searchField.setFocus();
+    //                }
+    //
+    //                if ( e.keyCode == 13 ) // return key
+    //                {
+    //                    openEditor( ( Table ) e.getSource() );
+    //                }
+    //            }
+    //        } );
+    //
+    //        resultsTable.addFocusListener( new FocusAdapter()
+    //        {
+    //            public void focusGained( FocusEvent e )
+    //            {
+    //                if ( ( resultsTable.getSelectionCount() == 0 ) && ( resultsTable.getItemCount()
!= 0 ) )
+    //                {
+    //                    resultsTable.select( 0 );
+    //                }
+    //            }
+    //        } );
+    //    }
+
+    //    /**
+    //     * Open the editor associated with the current selection in the table
+    //     *
+    //     * @param table
+    //     *      the associated table
+    //     */
+    //    private void openEditor( Table table )
+    //    {
+    //        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+    //
+    //        IEditorInput input = null;
+    //        String editorId = null;
+    //
+    //        // Here is the double clicked item
+    //        Object item = table.getSelection()[0].getData();
+    //        if ( item instanceof AttributeType )
+    //        {
+    //            input = new AttributeTypeEditorInput( ( AttributeType ) item );
+    //            editorId = AttributeTypeEditor.ID;
+    //        }
+    //        else if ( item instanceof ObjectClass )
+    //        {
+    //            input = new ObjectClassEditorInput( ( ObjectClass ) item );
+    //            editorId = ObjectClassEditor.ID;
+    //        }
+    //
+    //        // Let's open the editor
+    //        if ( input != null )
+    //        {
+    //            try
+    //            {
+    //                page.openEditor( input, editorId );
+    //            }
+    //            catch ( PartInitException exception )
+    //            {
+    //                Logger.getLogger( SchemasViewController.class ).debug( "error when
opening the editor" ); //$NON-NLS-1$
+    //            }
+    //        }
+    //    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+     */
+    @Override
+    public void setFocus()
+    {
+        if ( searchField != null && !searchField.isDisposed() )
+        {
+            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.
+     */
+    public void showSearchFieldSection()
+    {
+        createSearchField();
+        parent.layout( true, true );
+    }
+
+
+    /**
+     * Hides the Search Field Section.
+     */
+    public void hideSearchFieldSection()
+    {
+        if ( searchFieldInnerComposite != null )
+        {
+            searchFieldInnerComposite.dispose();
+            searchFieldInnerComposite = null;
+        }
+        if ( separatorLabel != null )
+        {
+            separatorLabel.dispose();
+            separatorLabel = null;
+        }
+        parent.layout( true, true );
+    }
+}



Mime
View raw message