You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2007/08/20 16:57:38 UTC
svn commit: r567721 - in
/directory/studio/trunk/studio-apacheds-schemaeditor: ./
src/main/java/org/apache/directory/studio/apacheds/schemaeditor/
src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/
src/main/java/org/apache/dire...
Author: pamarcelot
Date: Mon Aug 20 07:57:37 2007
New Revision: 567721
URL: http://svn.apache.org/viewvc?rev=567721&view=rev
Log:
Added a new preference page for the SearchView, as well as a sorting dialog for that view.
Added Actions to open the preference page and the sorting dialog.
Added SearchViewContentProvider that handles the displaying of the search results.
Added:
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSearchViewPreferenceAction.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSearchViewSortingDialogAction.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/SearchViewPreferencePage.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchViewContentProvider.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchViewSortingDialog.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/PreferenceInitializer.java
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/view/views/SchemaViewSortingDialog.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchView.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchViewLabelProvider.java
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml?rev=567721&r1=567720&r2=567721&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml Mon Aug 20 07:57:37 2007
@@ -196,6 +196,11 @@
</extension>
<extension
point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.apache.directory.studio.apacheds.schemaeditor.preferences.plugin"
+ class="org.apache.directory.studio.apacheds.schemaeditor.view.preferences.HierarchyViewPreferencePage"
+ id="org.apache.directory.studio.apacheds.schemaeditor.preferences.hierarchyView"
+ name="Hierarchy View"/>
<page
class="org.apache.directory.studio.apacheds.schemaeditor.view.preferences.PluginPreferencePage"
id="org.apache.directory.studio.apacheds.schemaeditor.preferences.plugin"
@@ -207,9 +212,9 @@
name="Schema View"/>
<page
category="org.apache.directory.studio.apacheds.schemaeditor.preferences.plugin"
- class="org.apache.directory.studio.apacheds.schemaeditor.view.preferences.HierarchyViewPreferencePage"
- id="org.apache.directory.studio.apacheds.schemaeditor.preferences.hierarchyView"
- name="Hierarchy View"/>
+ class="org.apache.directory.studio.apacheds.schemaeditor.view.preferences.SearchViewPreferencePage"
+ id="org.apache.directory.studio.apacheds.schemaeditor.preferences.searchView"
+ name="Search View"/>
</extension>
<extension
point="org.eclipse.ui.decorators">
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?rev=567721&r1=567720&r2=567721&view=diff
==============================================================================
--- 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 Mon Aug 20 07:57:37 2007
@@ -22,6 +22,7 @@
import org.apache.directory.studio.apacheds.schemaeditor.view.preferences.HierarchyViewPreferencePage;
import org.apache.directory.studio.apacheds.schemaeditor.view.preferences.SchemaViewPreferencePage;
+import org.apache.directory.studio.apacheds.schemaeditor.view.preferences.SearchViewPreferencePage;
/**
@@ -130,6 +131,10 @@
+ ".commands.openSchemaViewPreference";
public static final String CMD_OPEN_SCHEMA_VIEW_SORTING_DIALOG = Activator.PLUGIN_ID
+ ".commands.openSchemaViewSortingDialog";
+ public static final String CMD_OPEN_SEARCH_VIEW_PREFERENCE = Activator.PLUGIN_ID
+ + ".commands.openSearchViewPreference";
+ public static final String CMD_OPEN_SEARCH_VIEW_SORTING_DIALOG = Activator.PLUGIN_ID
+ + ".commands.openSearchViewSortingDialog";
public static final String CMD_OPEN_TYPE_HIERARCHY = Activator.PLUGIN_ID + ".commands.openTypeHierarchy";
public static final String CMD_NEW_ATTRIBUTE_TYPE = Activator.PLUGIN_ID + ".commands.newAttributeType";
public static final String CMD_NEW_OBJECT_CLASS = Activator.PLUGIN_ID + ".commands.newObjectClass";
@@ -230,34 +235,85 @@
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 */
+ // Search - SearchPage
+ /** The preference ID for Search History of the SearchPage */
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 */
+ /** The preference ID for Search Scope 'Aliases' of the SearchPage */
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 */
+ /** The preference ID for Search Scope 'OID' of the SearchPage */
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 */
+ /** The preference ID for Search Scope 'Description' of the SearchPage */
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 */
+ /** The preference ID for Search Scope 'Superior' of the SearchPage */
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 */
+ /** The preference ID for Search Scope 'Syntax' of the SearchPage */
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 */
+ /** The preference ID for Search Scope 'Matching Rules' of the SearchPage */
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 */
+ /** The preference ID for Search Scope 'Superiors' of the SearchPage */
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 */
+ /** The preference ID for Search Scope 'Mandatory Attributes' of the SearchPage */
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 */
+ /** The preference ID for Search Scope 'Optional Attributes' of the SearchPage */
public static final String PREFS_SEARCH_PAGE_SCOPE_OPTIONAL_ATTRIBUTES = Activator.PLUGIN_ID
+ ".preferences.SearchPage.scopeOptionalAttributes"; //$NON-NLS-1$
+
+ // Preferences - SearchView
+ /** The preference ID for Search View Label */
+ public static final String PREFS_SEARCH_VIEW_LABEL = SearchViewPreferencePage.ID + ".label.labelValue"; //$NON-NLS-1$
+ /** The preference value for Search View First Name label */
+ public static final int PREFS_SEARCH_VIEW_LABEL_FIRST_NAME = 0;
+ /** The preference value for Search View All Aliases label */
+ public static final int PREFS_SEARCH_VIEW_LABEL_ALL_ALIASES = 1;
+ /** The preference value for Search View OID label */
+ public static final int PREFS_SEARCH_VIEW_LABEL_OID = 2;
+ /** The preference ID for Search View Abbreviate */
+ public static final String PREFS_SEARCH_VIEW_ABBREVIATE = SearchViewPreferencePage.ID + ".label.abbreviate"; //$NON-NLS-1$
+ /** The preference ID for Search View Abbreviate Max Length*/
+ public static final String PREFS_SEARCH_VIEW_ABBREVIATE_MAX_LENGTH = SearchViewPreferencePage.ID
+ + ".label.abbreviate.maxLength"; //$NON-NLS-1$
+ /** The preference ID for Search View Display Secondary Label */
+ public static final String PREFS_SEARCH_VIEW_SECONDARY_LABEL_DISPLAY = SearchViewPreferencePage.ID
+ + ".secondaryLabel.display"; //$NON-NLS-1$
+ /** The preference ID for Search View Secondary Label */
+ public static final String PREFS_SEARCH_VIEW_SECONDARY_LABEL = SearchViewPreferencePage.ID
+ + ".secondaryLabel.labelValue"; //$NON-NLS-1$
+ /** The preference ID for Search View Abbreviate Secondary Label */
+ public static final String PREFS_SEARCH_VIEW_SECONDARY_LABEL_ABBREVIATE = SearchViewPreferencePage.ID
+ + ".secondaryLabel.abbreviate"; //$NON-NLS-1$
+ /** The preference ID for Search View Abbreviate Secondary Label Max Length*/
+ public static final String PREFS_SEARCH_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH = SearchViewPreferencePage.ID
+ + ".secondaryLabel.abbreviate.maxLength"; //$NON-NLS-1$
+ /** The preference ID for Search View Grouping */
+ public static final String PREFS_SEARCH_VIEW_GROUPING = Activator.PLUGIN_ID + ".preferences.SearchView.grouping"; //$NON-NLS-1$
+ /** The preference value for Search View Grouping 'Display ATs first' */
+ public static final int PREFS_SEARCH_VIEW_GROUPING_ATTRIBUTE_TYPES_FIRST = 0;
+ /** The preference value for Search View Grouping 'Display OCs first' */
+ public static final int PREFS_SEARCH_VIEW_GROUPING_OBJECT_CLASSES_FIRST = 1;
+ /** The preference value for Search View Grouping 'mixed' */
+ public static final int PREFS_SEARCH_VIEW_GROUPING_MIXED = 2;
+ /** The preference ID for Search View Sorting By */
+ public static final String PREFS_SEARCH_VIEW_SORTING_BY = Activator.PLUGIN_ID + ".preferences.SearchView.sortingBy"; //$NON-NLS-1$
+ /** The preference value for Search View Sorting 'First Name' */
+ public static final int PREFS_SEARCH_VIEW_SORTING_BY_FIRSTNAME = 0;
+ /** The preference value for Search View Sorting 'OID' */
+ public static final int PREFS_SEARCH_VIEW_SORTING_BY_OID = 1;
+ /** The preference ID for Sorting Order */
+ public static final String PREFS_SEARCH_VIEW_SORTING_ORDER = Activator.PLUGIN_ID
+ + ".preferences.SchemaView.sortingOrder"; //$NON-NLS-1$
+ /** The preference value for Search View Sorting 'ascending' */
+ public static final int PREFS_SEARCH_VIEW_SORTING_ORDER_ASCENDING = 0;
+ /** The preference value for Search View Sorting 'descending' */
+ public static final int PREFS_SEARCH_VIEW_SORTING_ORDER_DESCENDING = 1;
+ /** The preference ID for Search View Display Secondary Label */
+ public static final String PREFS_SEARCH_VIEW_SCHEMA_LABEL_DISPLAY = SearchViewPreferencePage.ID
+ + ".schemaLabel.display"; //$NON-NLS-1$
}
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PreferenceInitializer.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PreferenceInitializer.java?rev=567721&r1=567720&r2=567721&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PreferenceInitializer.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PreferenceInitializer.java Mon Aug 20 07:57:37 2007
@@ -43,7 +43,7 @@
store.setDefault( PluginConstants.PREFS_DIFFERENCES_WIDGET_GROUPING,
PluginConstants.PREFS_DIFFERENCES_WIDGET_GROUPING_PROPERTY );
- // Schema View Preference Page
+ // SchemaView Preference Page
store.setDefault( PluginConstants.PREFS_SCHEMA_VIEW_LABEL, PluginConstants.PREFS_SCHEMA_VIEW_LABEL_ALL_ALIASES );
store.setDefault( PluginConstants.PREFS_SCHEMA_VIEW_ABBREVIATE, true );
store.setDefault( PluginConstants.PREFS_SCHEMA_VIEW_ABBREVIATE_MAX_LENGTH, "50" ); //$NON-NLS-1$
@@ -53,7 +53,15 @@
store.setDefault( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE, false );
store.setDefault( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH, "50" ); //$NON-NLS-1$
- // Hierarchy View Preference Page
+ // SchemaView Sorting
+ store.setDefault( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING,
+ PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_FOLDERS );
+ store.setDefault( PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY,
+ PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY_FIRSTNAME );
+ store.setDefault( PluginConstants.PREFS_SCHEMA_VIEW_SORTING_ORDER,
+ PluginConstants.PREFS_SCHEMA_VIEW_SORTING_ORDER_ASCENDING );
+
+ // HierarchyView Preference Page
store.setDefault( PluginConstants.PREFS_HIERARCHY_VIEW_LABEL,
PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES );
store.setDefault( PluginConstants.PREFS_HIERARCHY_VIEW_ABBREVIATE, true );
@@ -63,5 +71,23 @@
PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_OID );
store.setDefault( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE, false );
store.setDefault( PluginConstants.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH, "50" ); //$NON-NLS-1$
+
+ // SearchView Preference Page
+ store.setDefault( PluginConstants.PREFS_SEARCH_VIEW_LABEL, PluginConstants.PREFS_SEARCH_VIEW_LABEL_ALL_ALIASES );
+ store.setDefault( PluginConstants.PREFS_SEARCH_VIEW_ABBREVIATE, true );
+ store.setDefault( PluginConstants.PREFS_SEARCH_VIEW_ABBREVIATE_MAX_LENGTH, "50" ); //$NON-NLS-1$
+ store.setDefault( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_DISPLAY, true );
+ store.setDefault( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL,
+ PluginConstants.PREFS_SEARCH_VIEW_LABEL_OID );
+ store.setDefault( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_ABBREVIATE, false );
+ store.setDefault( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH, "50" ); //$NON-NLS-1$
+ store.setDefault( PluginConstants.PREFS_SEARCH_VIEW_SCHEMA_LABEL_DISPLAY, true );
+
+ // SearchView Sorting
+ store.setDefault( PluginConstants.PREFS_SEARCH_VIEW_GROUPING, PluginConstants.PREFS_SEARCH_VIEW_GROUPING_MIXED );
+ store.setDefault( PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY,
+ PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY_FIRSTNAME );
+ store.setDefault( PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER,
+ PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER_ASCENDING );
}
}
Modified: 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?rev=567721&r1=567720&r2=567721&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SearchViewController.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SearchViewController.java Mon Aug 20 07:57:37 2007
@@ -20,12 +20,22 @@
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.OpenSearchViewPreferenceAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.OpenSearchViewSortingDialogAction;
import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.RunCurrentSearchAgainAction;
import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ShowSearchFieldAction;
import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ShowSearchHistoryAction;
import org.apache.directory.studio.apacheds.schemaeditor.view.views.SearchView;
+import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
/**
@@ -39,10 +49,15 @@
/** The associated view */
private SearchView view;
+ /** The authorized Preferences keys*/
+ private List<String> authorizedPrefs;
+
// The Actions
private ShowSearchFieldAction showSearchField;
private RunCurrentSearchAgainAction runCurrentSearchAgain;
private ShowSearchHistoryAction searchHistory;
+ private OpenSearchViewSortingDialogAction openSearchViewSortingDialog;
+ private OpenSearchViewPreferenceAction openSearchViewPreference;
/**
@@ -57,6 +72,9 @@
initActions();
initToolbar();
+ initMenu();
+ initAuthorizedPrefs();
+ initPreferencesListener();
}
@@ -68,6 +86,8 @@
showSearchField = new ShowSearchFieldAction( view );
runCurrentSearchAgain = new RunCurrentSearchAgainAction( view );
searchHistory = new ShowSearchHistoryAction( view );
+ openSearchViewSortingDialog = new OpenSearchViewSortingDialogAction();
+ openSearchViewPreference = new OpenSearchViewPreferenceAction();
}
@@ -81,5 +101,58 @@
toolbar.add( new Separator() );
toolbar.add( runCurrentSearchAgain );
toolbar.add( searchHistory );
+ }
+
+
+ /**
+ * Initializes the Menu.
+ */
+ private void initMenu()
+ {
+ IMenuManager menu = view.getViewSite().getActionBars().getMenuManager();
+ menu.add( openSearchViewSortingDialog );
+ menu.add( new Separator() );
+ menu.add( openSearchViewPreference );
+ }
+
+
+ /**
+ * Initializes the Authorized Prefs IDs.
+ */
+ private void initAuthorizedPrefs()
+ {
+ authorizedPrefs = new ArrayList<String>();
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_LABEL );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_ABBREVIATE );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_ABBREVIATE_MAX_LENGTH );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_DISPLAY );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_ABBREVIATE );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_SCHEMA_LABEL_DISPLAY );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_GROUPING );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER );
+ }
+
+
+ /**
+ * Initializes the listener on the preferences store
+ */
+ private void initPreferencesListener()
+ {
+ Activator.getDefault().getPreferenceStore().addPropertyChangeListener( new IPropertyChangeListener()
+ {
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ if ( authorizedPrefs.contains( event.getProperty() ) )
+ {
+ view.refresh();
+ }
+ }
+ } );
}
}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSearchViewPreferenceAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSearchViewPreferenceAction.java?rev=567721&view=auto
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSearchViewPreferenceAction.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSearchViewPreferenceAction.java Mon Aug 20 07:57:37 2007
@@ -0,0 +1,101 @@
+/*
+ * 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.PluginConstants;
+import org.apache.directory.studio.apacheds.schemaeditor.view.preferences.SchemaViewPreferencePage;
+import org.apache.directory.studio.apacheds.schemaeditor.view.preferences.SearchViewPreferencePage;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+
+/**
+ * This action opens the Preference Page for the SearchView.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class OpenSearchViewPreferenceAction extends Action implements IWorkbenchWindowActionDelegate
+{
+ /**
+ * Creates a new instance of OpenSearchViewPreferenceAction.
+ */
+ public OpenSearchViewPreferenceAction()
+ {
+ super( "&Preferences..." );
+ setToolTipText( "Preferences..." );
+ setId( PluginConstants.CMD_OPEN_SEARCH_VIEW_PREFERENCE );
+ setEnabled( true );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run()
+ {
+ Shell shell = Display.getCurrent().getActiveShell();
+ PreferencesUtil.createPreferenceDialogOn( shell, SearchViewPreferencePage.ID, new String[]
+ { SearchViewPreferencePage.ID }, null ).open();
+ }
+
+
+ /* (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
+ }
+}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSearchViewSortingDialogAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSearchViewSortingDialogAction.java?rev=567721&view=auto
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSearchViewSortingDialogAction.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSearchViewSortingDialogAction.java Mon Aug 20 07:57:37 2007
@@ -0,0 +1,102 @@
+/*
+ * 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.SearchViewSortingDialog;
+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.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This action opens the Sorting Dialog for the SearchView.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class OpenSearchViewSortingDialogAction extends Action implements IWorkbenchWindowActionDelegate
+{
+ /**
+ * Creates a new instance of OpenSearchViewSortingDialogAction.
+ */
+ public OpenSearchViewSortingDialogAction()
+ {
+ super( "&Sorting..." );
+ setToolTipText( "Sorting..." );
+ setId( PluginConstants.CMD_OPEN_SEARCH_VIEW_SORTING_DIALOG );
+ setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ PluginConstants.IMG_SORTING ) );
+ setEnabled( true );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run()
+ {
+ SearchViewSortingDialog svsd = new SearchViewSortingDialog( PlatformUI.getWorkbench().getDisplay()
+ .getActiveShell() );
+ svsd.open();
+ }
+
+
+ /* (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
+ }
+}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/SearchViewPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/SearchViewPreferencePage.java?rev=567721&view=auto
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/SearchViewPreferencePage.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/SearchViewPreferencePage.java Mon Aug 20 07:57:37 2007
@@ -0,0 +1,456 @@
+/*
+ * 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.preferences;
+
+
+import org.apache.directory.studio.apacheds.schemaeditor.Activator;
+import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+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.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+/**
+ * This class implements the Preference page for the Search View
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchViewPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+ /** The preference page ID */
+ public static final String ID = Activator.PLUGIN_ID + ".preferences.searchView"; //$NON-NLS-1$
+
+ /** The First Name category */
+ private static final String FIRST_NAME = "First Name";
+
+ /** The All Aliases category */
+ private static final String ALL_ALIASES = "All Aliases";
+
+ /** The OID category */
+ private static final String OID = "OID";
+
+ // UI fields
+ private Combo labelCombo;
+ private Button limitButton;
+ private Text lengthText;
+ private Button secondaryLabelButtonDisplay;
+ private Combo secondaryLabelCombo;
+ private Button secondaryLabelLimitButton;
+ private Text secondaryLabelLengthText;
+ private Button schemaLabelButtonDisplay;
+
+
+ /**
+ * Creates a new instance of SchemaViewPreferencePage.
+ */
+ public SearchViewPreferencePage()
+ {
+ super();
+ setPreferenceStore( Activator.getDefault().getPreferenceStore() );
+ setDescription( "General settings for the Search View of the Schema Editor Plugin" );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createContents( Composite parent )
+ {
+ Composite composite = new Composite( parent, SWT.NONE );
+ composite.setLayout( new GridLayout() );
+ composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+
+ // Label Group
+ Group labelGroup = new Group( composite, SWT.NONE );
+ labelGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ labelGroup.setText( "Label" );
+ labelGroup.setLayout( new GridLayout() );
+ Composite labelGroupComposite = new Composite( labelGroup, SWT.NONE );
+ GridLayout gl = new GridLayout( 1, false );
+ gl.marginHeight = gl.marginWidth = 0;
+ labelGroupComposite.setLayout( gl );
+ labelGroupComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Label row composite
+ Composite labelComposite = new Composite( labelGroupComposite, SWT.NONE );
+ gl = new GridLayout( 3, false );
+ gl.marginHeight = gl.marginWidth = 0;
+ labelComposite.setLayout( gl );
+ GridData gd = new GridData( SWT.FILL, SWT.NONE, true, false );
+ gd.horizontalSpan = 1;
+ labelComposite.setLayoutData( gd );
+
+ // Use Label
+ Label useLabel = new Label( labelComposite, SWT.NONE );
+ useLabel.setText( "Use" );
+
+ // Label Combo
+ labelCombo = new Combo( labelComposite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER );
+ labelCombo.setLayoutData( new GridData() );
+ labelCombo.setItems( new String[]
+ { FIRST_NAME, ALL_ALIASES, OID } );
+ labelCombo.setEnabled( true );
+
+ // As label Label
+ Label asLabel = new Label( labelComposite, SWT.NONE );
+ asLabel.setText( "as label." );
+
+ // Abbreviate row composite
+ Composite abbreviateComposite = new Composite( labelGroupComposite, SWT.NONE );
+ gl = new GridLayout( 3, false );
+ gl.marginHeight = gl.marginWidth = 0;
+ abbreviateComposite.setLayout( gl );
+ gd = new GridData( SWT.FILL, SWT.NONE, true, false );
+ gd.horizontalSpan = 1;
+ abbreviateComposite.setLayoutData( gd );
+
+ // Limit label lenght to Label
+ limitButton = new Button( abbreviateComposite, SWT.CHECK );
+ limitButton.setText( "Limit label length to" );
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ limitButton.setLayoutData( gd );
+
+ // Lenght Text
+ lengthText = new Text( abbreviateComposite, SWT.NONE | SWT.BORDER );
+ GridData gridData = new GridData();
+ gridData.horizontalSpan = 1;
+ gridData.widthHint = 9 * 3;
+ lengthText.setLayoutData( gridData );
+ lengthText.setTextLimit( 3 );
+ lengthText.addVerifyListener( new VerifyListener()
+ {
+ public void verifyText( VerifyEvent e )
+ {
+ if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
+ {
+ e.doit = false;
+ }
+ if ( "".equals( lengthText.getText() ) && e.text.matches( "[0]" ) ) //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ e.doit = false;
+ }
+ }
+ } );
+
+ // Characters Label
+ Label charactersLabel = new Label( abbreviateComposite, SWT.NONE );
+ charactersLabel.setText( "characters." );
+
+ // Secondary Label Group
+ Group secondaryLabelGroup = new Group( composite, SWT.NONE );
+ secondaryLabelGroup.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+ secondaryLabelGroup.setText( "Secondary label" );
+ secondaryLabelGroup.setLayout( new GridLayout() );
+ Composite secondaryLabelGroupComposite = new Composite( secondaryLabelGroup, SWT.NONE );
+ gl = new GridLayout( 1, false );
+ gl.marginHeight = gl.marginWidth = 0;
+ secondaryLabelGroupComposite.setLayout( gl );
+ secondaryLabelGroupComposite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+ secondaryLabelButtonDisplay = new Button( secondaryLabelGroupComposite, SWT.CHECK );
+ secondaryLabelButtonDisplay.setText( "Display secondary label." );
+
+ // Label row composite
+ Composite secondaryLabelComposite = new Composite( secondaryLabelGroupComposite, SWT.NONE );
+ gl = new GridLayout( 3, false );
+ gl.marginHeight = gl.marginWidth = 0;
+ secondaryLabelComposite.setLayout( gl );
+ gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.horizontalSpan = 1;
+ secondaryLabelComposite.setLayoutData( gd );
+
+ // Use Label
+ Label useLabel2 = new Label( secondaryLabelComposite, SWT.NONE );
+ useLabel2.setText( "Use" );
+
+ // Label Combo
+ secondaryLabelCombo = new Combo( secondaryLabelComposite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER );
+ secondaryLabelCombo.setLayoutData( new GridData() );
+ secondaryLabelCombo.setItems( new String[]
+ { FIRST_NAME, ALL_ALIASES, OID } );
+ secondaryLabelCombo.setEnabled( true );
+
+ // As label Label
+ Label asLabel2 = new Label( secondaryLabelComposite, SWT.NONE );
+ asLabel2.setText( "as secondary label." );
+
+ // Abbreviate row composite
+ Composite abbreviateComposite2 = new Composite( secondaryLabelGroup, SWT.NONE );
+ gl = new GridLayout( 3, false );
+ gl.marginHeight = gl.marginWidth = 0;
+ abbreviateComposite2.setLayout( gl );
+ gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.horizontalSpan = 1;
+ abbreviateComposite2.setLayoutData( gd );
+
+ // Limit label lenght to Label
+ secondaryLabelLimitButton = new Button( abbreviateComposite2, SWT.CHECK );
+ secondaryLabelLimitButton.setText( "Limit secondary label length to" );
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ secondaryLabelLimitButton.setLayoutData( gd );
+
+ // Lenght Text
+ secondaryLabelLengthText = new Text( abbreviateComposite2, SWT.NONE | SWT.BORDER );
+ gridData = new GridData();
+ gridData.horizontalSpan = 1;
+ gridData.widthHint = 9 * 3;
+ secondaryLabelLengthText.setLayoutData( gridData );
+ secondaryLabelLengthText.setTextLimit( 3 );
+ secondaryLabelLengthText.addVerifyListener( new VerifyListener()
+ {
+ public void verifyText( VerifyEvent e )
+ {
+ if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
+ {
+ e.doit = false;
+ }
+ if ( "".equals( secondaryLabelLengthText.getText() ) && e.text.matches( "[0]" ) ) //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ e.doit = false;
+ }
+ }
+ } );
+
+ // Characters Label
+ Label secondaryLabelcharactersLabel = new Label( abbreviateComposite2, SWT.NONE );
+ secondaryLabelcharactersLabel.setText( "characters." );
+
+ // Schema Label Group
+ Group schemaLabelGroup = new Group( composite, SWT.NONE );
+ schemaLabelGroup.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+ schemaLabelGroup.setText( "Schema label" );
+ schemaLabelGroup.setLayout( new GridLayout() );
+ Composite schemaLabelGroupComposite = new Composite( schemaLabelGroup, SWT.NONE );
+ gl = new GridLayout( 1, false );
+ gl.marginHeight = gl.marginWidth = 0;
+ schemaLabelGroupComposite.setLayout( gl );
+ schemaLabelGroupComposite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+ schemaLabelButtonDisplay = new Button( schemaLabelGroupComposite, SWT.CHECK );
+ schemaLabelButtonDisplay.setText( "Display schema name in label." );
+
+ initFieldsFromPreferences();
+
+ initListeners();
+
+ applyDialogFont( parent );
+
+ return parent;
+ }
+
+
+ /**
+ * Initializes the fields from the preferences store.
+ */
+ private void initFieldsFromPreferences()
+ {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+
+ labelCombo.select( store.getInt( PluginConstants.PREFS_SEARCH_VIEW_LABEL ) );
+ limitButton.setSelection( store.getBoolean( PluginConstants.PREFS_SEARCH_VIEW_ABBREVIATE ) );
+ lengthText.setEnabled( limitButton.getSelection() );
+ lengthText.setText( store.getString( PluginConstants.PREFS_SEARCH_VIEW_ABBREVIATE_MAX_LENGTH ) );
+
+ secondaryLabelButtonDisplay.setSelection( store
+ .getBoolean( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_DISPLAY ) );
+ secondaryLabelCombo.select( store.getInt( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL ) );
+ secondaryLabelLimitButton.setSelection( store
+ .getBoolean( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_ABBREVIATE ) );
+ secondaryLabelLengthText.setText( store
+ .getString( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH ) );
+ if ( store.getBoolean( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_DISPLAY ) )
+ {
+ secondaryLabelCombo.setEnabled( true );
+ secondaryLabelLimitButton.setEnabled( true );
+ secondaryLabelLengthText.setEnabled( secondaryLabelLimitButton.getSelection() );
+ }
+ else
+ {
+ secondaryLabelCombo.setEnabled( false );
+ secondaryLabelLimitButton.setEnabled( false );
+ secondaryLabelLengthText.setEnabled( false );
+ }
+
+ schemaLabelButtonDisplay.setSelection( store
+ .getBoolean( PluginConstants.PREFS_SEARCH_VIEW_SCHEMA_LABEL_DISPLAY ) );
+ }
+
+
+ /**
+ * Initializes the listeners.
+ */
+ private void initListeners()
+ {
+ limitButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ lengthText.setEnabled( limitButton.getSelection() );
+ }
+ } );
+
+ secondaryLabelButtonDisplay.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ if ( secondaryLabelButtonDisplay.getSelection() )
+ {
+ secondaryLabelCombo.setEnabled( true );
+ secondaryLabelLimitButton.setEnabled( true );
+ secondaryLabelLengthText.setEnabled( secondaryLabelLimitButton.getSelection() );
+ }
+ else
+ {
+ secondaryLabelCombo.setEnabled( false );
+ secondaryLabelLimitButton.setEnabled( false );
+ secondaryLabelLengthText.setEnabled( false );
+ }
+ }
+ } );
+
+ secondaryLabelLimitButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ secondaryLabelLengthText.setEnabled( secondaryLabelLimitButton.getSelection() );
+ }
+ } );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+ protected void performDefaults()
+ {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+
+ labelCombo.select( store.getDefaultInt( PluginConstants.PREFS_SEARCH_VIEW_LABEL ) );
+ limitButton.setSelection( store.getDefaultBoolean( PluginConstants.PREFS_SEARCH_VIEW_ABBREVIATE ) );
+ lengthText.setEnabled( limitButton.getSelection() );
+ lengthText.setText( store.getDefaultString( PluginConstants.PREFS_SEARCH_VIEW_ABBREVIATE_MAX_LENGTH ) );
+
+ secondaryLabelButtonDisplay.setSelection( store
+ .getDefaultBoolean( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_DISPLAY ) );
+ secondaryLabelCombo.select( store.getDefaultInt( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL ) );
+ secondaryLabelLimitButton.setSelection( store
+ .getDefaultBoolean( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_ABBREVIATE ) );
+ secondaryLabelLengthText.setText( store
+ .getDefaultString( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH ) );
+
+ if ( secondaryLabelButtonDisplay.getSelection() )
+ {
+ secondaryLabelCombo.setEnabled( true );
+ secondaryLabelLimitButton.setEnabled( true );
+ secondaryLabelLengthText.setEnabled( secondaryLabelLimitButton.getSelection() );
+ }
+ else
+ {
+ secondaryLabelCombo.setEnabled( false );
+ secondaryLabelLimitButton.setEnabled( false );
+ secondaryLabelLengthText.setEnabled( false );
+ }
+
+ schemaLabelButtonDisplay.setSelection( store
+ .getDefaultBoolean( PluginConstants.PREFS_SEARCH_VIEW_SCHEMA_LABEL_DISPLAY ) );
+
+ super.performDefaults();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performOk()
+ */
+ public boolean performOk()
+ {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+
+ if ( labelCombo.getItem( labelCombo.getSelectionIndex() ).equals( FIRST_NAME ) )
+ {
+ store
+ .setValue( PluginConstants.PREFS_SEARCH_VIEW_LABEL, PluginConstants.PREFS_SEARCH_VIEW_LABEL_FIRST_NAME );
+ }
+ else if ( labelCombo.getItem( labelCombo.getSelectionIndex() ).equals( ALL_ALIASES ) )
+ {
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_LABEL,
+ PluginConstants.PREFS_SEARCH_VIEW_LABEL_ALL_ALIASES );
+ }
+ else if ( labelCombo.getItem( labelCombo.getSelectionIndex() ).equals( OID ) )
+ {
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_LABEL, PluginConstants.PREFS_SEARCH_VIEW_LABEL_OID );
+ }
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_ABBREVIATE, limitButton.getSelection() );
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_ABBREVIATE_MAX_LENGTH, lengthText.getText() );
+
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_DISPLAY, secondaryLabelButtonDisplay
+ .getSelection() );
+ if ( secondaryLabelCombo.getItem( secondaryLabelCombo.getSelectionIndex() ).equals( FIRST_NAME ) )
+ {
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL,
+ PluginConstants.PREFS_SEARCH_VIEW_LABEL_FIRST_NAME );
+ }
+ else if ( secondaryLabelCombo.getItem( secondaryLabelCombo.getSelectionIndex() ).equals( ALL_ALIASES ) )
+ {
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL,
+ PluginConstants.PREFS_SEARCH_VIEW_LABEL_ALL_ALIASES );
+ }
+ else if ( secondaryLabelCombo.getItem( secondaryLabelCombo.getSelectionIndex() ).equals( OID ) )
+ {
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL,
+ PluginConstants.PREFS_SEARCH_VIEW_LABEL_OID );
+ }
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_ABBREVIATE, secondaryLabelLimitButton
+ .getSelection() );
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH,
+ secondaryLabelLengthText.getText() );
+
+ store
+ .setValue( PluginConstants.PREFS_SEARCH_VIEW_SCHEMA_LABEL_DISPLAY, schemaLabelButtonDisplay.getSelection() );
+
+ return true;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init( IWorkbench workbench )
+ {
+ // Nothing to do
+ }
+}
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaViewSortingDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaViewSortingDialog.java?rev=567721&r1=567720&r2=567721&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaViewSortingDialog.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaViewSortingDialog.java Mon Aug 20 07:57:37 2007
@@ -198,12 +198,12 @@
if ( buttonId == IDialogConstants.OK_ID )
{
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- if ( ( inFoldersButton.getSelection() ) & ( !mixedButton.getSelection() ) )
+ if ( ( inFoldersButton.getSelection() ) && ( !mixedButton.getSelection() ) )
{
store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING,
PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_FOLDERS );
}
- else if ( ( !inFoldersButton.getSelection() ) & ( mixedButton.getSelection() ) )
+ else if ( ( !inFoldersButton.getSelection() ) && ( mixedButton.getSelection() ) )
{
store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING,
PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_MIXED );
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?rev=567721&r1=567720&r2=567721&view=diff
==============================================================================
--- 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 Mon Aug 20 07:57:37 2007
@@ -36,7 +36,6 @@
import org.apache.directory.studio.apacheds.schemaeditor.view.search.SearchPage;
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.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyAdapter;
@@ -404,7 +403,7 @@
// Creating the TableViewer
resultsTableViewer = new TableViewer( resultsTable );
resultsTableViewer.setLabelProvider( new SearchViewLabelProvider() );
- resultsTableViewer.setContentProvider( new ArrayContentProvider() );
+ resultsTableViewer.setContentProvider( new SearchViewContentProvider() );
}
@@ -894,5 +893,14 @@
public String getSearchString()
{
return searchString;
+ }
+
+
+ /**
+ * Refreshes the view.
+ */
+ public void refresh()
+ {
+ resultsTableViewer.refresh();
}
}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchViewContentProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchViewContentProvider.java?rev=567721&view=auto
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchViewContentProvider.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchViewContentProvider.java Mon Aug 20 07:57:37 2007
@@ -0,0 +1,344 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+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.model.AttributeTypeImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.ObjectClassWrapper;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.TreeNode;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+
+/**
+ * This class implements the ContentProvider for the SchemaView.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchViewContentProvider implements IStructuredContentProvider, ITreeContentProvider
+{
+ /** The preferences store */
+ private IPreferenceStore store;
+
+ /** The FirstName Sorter */
+ private Comparator<SchemaObject> firstNameSorter;
+
+ /** The OID Sorter */
+ private Comparator<SchemaObject> oidSorter;
+
+
+ /**
+ * Creates a new instance of DifferencesWidgetSchemaContentProvider.
+ */
+ public SearchViewContentProvider()
+ {
+ store = Activator.getDefault().getPreferenceStore();
+
+ firstNameSorter = new Comparator<SchemaObject>()
+ {
+ public int compare( SchemaObject o1, SchemaObject o2 )
+ {
+ String[] o1Names = null;
+ String[] o2Names = null;
+
+ if ( ( o1 instanceof AttributeTypeImpl ) && ( o2 instanceof AttributeTypeImpl ) )
+ {
+ AttributeTypeImpl at1 = ( AttributeTypeImpl ) o1;
+ AttributeTypeImpl at2 = ( AttributeTypeImpl ) o2;
+
+ o1Names = at1.getNames();
+ o2Names = at2.getNames();
+ }
+ else if ( ( o1 instanceof ObjectClassImpl ) && ( o2 instanceof ObjectClassImpl ) )
+ {
+ ObjectClassImpl oc1 = ( ObjectClassImpl ) o1;
+ ObjectClassImpl oc2 = ( ObjectClassImpl ) o2;
+
+ o1Names = oc1.getNames();
+ o2Names = oc2.getNames();
+ }
+ else if ( ( o1 instanceof AttributeTypeImpl ) && ( o2 instanceof ObjectClassImpl ) )
+ {
+ AttributeTypeImpl at = ( AttributeTypeImpl ) o1;
+ ObjectClassImpl oc = ( ObjectClassImpl ) o2;
+
+ o1Names = at.getNames();
+ o2Names = oc.getNames();
+ }
+ else if ( ( o1 instanceof ObjectClassImpl ) && ( o2 instanceof AttributeTypeImpl ) )
+ {
+ ObjectClassImpl oc = ( ObjectClassImpl ) o1;
+ AttributeTypeImpl at = ( AttributeTypeImpl ) o2;
+
+ o1Names = oc.getNames();
+ o2Names = at.getNames();
+ }
+
+ // Comparing the First Name
+ if ( ( o1Names != null ) && ( o2Names != null ) )
+ {
+ if ( ( o1Names.length > 0 ) && ( o2Names.length > 0 ) )
+ {
+ return o1Names[0].compareToIgnoreCase( o2Names[0] );
+ }
+ else if ( ( o1Names.length == 0 ) && ( o2Names.length > 0 ) )
+ {
+ return "".compareToIgnoreCase( o2Names[0] );
+ }
+ else if ( ( o1Names.length > 0 ) && ( o2Names.length == 0 ) )
+ {
+ return o1Names[0].compareToIgnoreCase( "" );
+ }
+ }
+
+ // Default
+ return o1.toString().compareToIgnoreCase( o2.toString() );
+ }
+ };
+
+ oidSorter = new Comparator<SchemaObject>()
+ {
+ public int compare( SchemaObject o1, SchemaObject o2 )
+ {
+ if ( ( o1 instanceof AttributeTypeImpl ) && ( o2 instanceof AttributeTypeImpl ) )
+ {
+ AttributeTypeImpl at1 = ( AttributeTypeImpl ) o1;
+ AttributeTypeImpl at2 = ( AttributeTypeImpl ) o2;
+
+ return at1.getOid().compareToIgnoreCase( at2.getOid() );
+ }
+ else if ( ( o1 instanceof ObjectClassImpl ) && ( o2 instanceof ObjectClassImpl ) )
+ {
+ ObjectClassImpl oc1 = ( ObjectClassImpl ) o1;
+ ObjectClassImpl oc2 = ( ObjectClassImpl ) o2;
+
+ return oc1.getOid().compareToIgnoreCase( oc2.getOid() );
+ }
+ else if ( ( o1 instanceof AttributeTypeImpl ) && ( o2 instanceof ObjectClassImpl ) )
+ {
+ AttributeTypeImpl at = ( AttributeTypeImpl ) o1;
+ ObjectClassImpl oc = ( ObjectClassImpl ) o2;
+
+ return at.getOid().compareToIgnoreCase( oc.getOid() );
+ }
+ else if ( ( o1 instanceof ObjectClassWrapper ) && ( o2 instanceof AttributeTypeImpl ) )
+ {
+ ObjectClassImpl oc = ( ObjectClassImpl ) o1;
+ AttributeTypeImpl at = ( AttributeTypeImpl ) o2;
+
+ return oc.getOid().compareToIgnoreCase( at.getOid() );
+ }
+
+ // Default
+ return o1.toString().compareToIgnoreCase( o2.toString() );
+ }
+ };
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements( Object inputElement )
+ {
+ return getChildren( inputElement );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose()
+ {
+ // Nothing to do
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+ {
+ // Nothing to do
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ */
+ @SuppressWarnings("unchecked")
+ public Object[] getChildren( Object parentElement )
+ {
+ List<SchemaObject> children = new ArrayList<SchemaObject>();
+
+ int group = store.getInt( PluginConstants.PREFS_SEARCH_VIEW_GROUPING );
+ int sortBy = store.getInt( PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY );
+ int sortOrder = store.getInt( PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER );
+
+ if ( parentElement instanceof List )
+ {
+ List<SchemaObject> searchResults = ( List<SchemaObject> ) parentElement;
+
+ if ( group == PluginConstants.PREFS_SEARCH_VIEW_GROUPING_ATTRIBUTE_TYPES_FIRST )
+ {
+ List<AttributeTypeImpl> attributeTypes = new ArrayList<AttributeTypeImpl>();
+ List<ObjectClassImpl> objectClasses = new ArrayList<ObjectClassImpl>();
+
+ for ( SchemaObject searchResult : searchResults )
+ {
+ if ( searchResult instanceof AttributeTypeImpl )
+ {
+ attributeTypes.add( ( AttributeTypeImpl ) searchResult );
+ }
+ else if ( searchResult instanceof ObjectClassImpl )
+ {
+ objectClasses.add( ( ObjectClassImpl ) searchResult );
+ }
+ }
+
+ // Sort by
+ if ( sortBy == PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY_FIRSTNAME )
+ {
+ Collections.sort( attributeTypes, firstNameSorter );
+ Collections.sort( objectClasses, firstNameSorter );
+ }
+ else if ( sortBy == PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY_OID )
+ {
+ Collections.sort( attributeTypes, oidSorter );
+ Collections.sort( objectClasses, oidSorter );
+ }
+
+ // Sort Order
+ if ( sortOrder == PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER_DESCENDING )
+ {
+ Collections.reverse( attributeTypes );
+ Collections.reverse( objectClasses );
+ }
+
+ children.addAll( attributeTypes );
+ children.addAll( objectClasses );
+ }
+ else if ( group == PluginConstants.PREFS_SEARCH_VIEW_GROUPING_OBJECT_CLASSES_FIRST )
+ {
+ List<AttributeTypeImpl> attributeTypes = new ArrayList<AttributeTypeImpl>();
+ List<ObjectClassImpl> objectClasses = new ArrayList<ObjectClassImpl>();
+
+ for ( SchemaObject searchResult : searchResults )
+ {
+ if ( searchResult instanceof AttributeTypeImpl )
+ {
+ attributeTypes.add( ( AttributeTypeImpl ) searchResult );
+ }
+ else if ( searchResult instanceof ObjectClassImpl )
+ {
+ objectClasses.add( ( ObjectClassImpl ) searchResult );
+ }
+ }
+
+ // Sort by
+ if ( sortBy == PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY_FIRSTNAME )
+ {
+ Collections.sort( attributeTypes, firstNameSorter );
+ Collections.sort( objectClasses, firstNameSorter );
+ }
+ else if ( sortBy == PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY_OID )
+ {
+ Collections.sort( attributeTypes, oidSorter );
+ Collections.sort( objectClasses, oidSorter );
+ }
+
+ // Sort Order
+ if ( sortOrder == PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER_DESCENDING )
+ {
+ Collections.reverse( attributeTypes );
+ Collections.reverse( objectClasses );
+ }
+
+ children.addAll( objectClasses );
+ children.addAll( attributeTypes );
+ }
+ else if ( group == PluginConstants.PREFS_SEARCH_VIEW_GROUPING_MIXED )
+ {
+ children.addAll( searchResults );
+
+ // Sort by
+ if ( sortBy == PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY_FIRSTNAME )
+ {
+ Collections.sort( children, firstNameSorter );
+ }
+ else if ( sortBy == PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY_OID )
+ {
+ Collections.sort( children, oidSorter );
+ }
+
+ // Sort Order
+ if ( sortOrder == PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER_DESCENDING )
+ {
+ Collections.reverse( children );
+ }
+ }
+ }
+
+ return children.toArray();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ */
+ public Object getParent( Object element )
+ {
+
+ if ( element instanceof TreeNode )
+ {
+ return ( ( TreeNode ) element ).getParent();
+ }
+
+ // Default
+ return null;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+ */
+ public boolean hasChildren( Object element )
+ {
+ if ( element instanceof TreeNode )
+ {
+ return ( ( TreeNode ) element ).hasChildren();
+ }
+
+ // Default
+ return false;
+ }
+}
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchViewLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchViewLabelProvider.java?rev=567721&r1=567720&r2=567721&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchViewLabelProvider.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchViewLabelProvider.java Mon Aug 20 07:57:37 2007
@@ -20,12 +20,12 @@
package org.apache.directory.studio.apacheds.schemaeditor.view.views;
+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.model.AttributeTypeImpl;
import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
import org.apache.directory.studio.apacheds.schemaeditor.view.ViewUtils;
-import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.Folder;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
@@ -62,22 +62,23 @@
{
String label = ""; //$NON-NLS-1$
- int labelValue = store.getInt( PluginConstants.PREFS_SCHEMA_VIEW_LABEL );
- boolean abbreviate = store.getBoolean( PluginConstants.PREFS_SCHEMA_VIEW_ABBREVIATE );
- int abbreviateMaxLength = store.getInt( PluginConstants.PREFS_SCHEMA_VIEW_ABBREVIATE_MAX_LENGTH );
- boolean secondaryLabelDisplay = store.getBoolean( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_DISPLAY );
- int secondaryLabelValue = store.getInt( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL );
+ int labelValue = store.getInt( PluginConstants.PREFS_SEARCH_VIEW_LABEL );
+ boolean abbreviate = store.getBoolean( PluginConstants.PREFS_SEARCH_VIEW_ABBREVIATE );
+ int abbreviateMaxLength = store.getInt( PluginConstants.PREFS_SEARCH_VIEW_ABBREVIATE_MAX_LENGTH );
+ boolean secondaryLabelDisplay = store.getBoolean( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_DISPLAY );
+ int secondaryLabelValue = store.getInt( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL );
boolean secondaryLabelAbbreviate = store
- .getBoolean( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE );
+ .getBoolean( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_ABBREVIATE );
int secondaryLabelAbbreviateMaxLength = store
- .getInt( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH );
+ .getInt( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH );
+ boolean schemaLabelDisplay = store.getBoolean( PluginConstants.PREFS_SEARCH_VIEW_SCHEMA_LABEL_DISPLAY );
if ( element instanceof AttributeTypeImpl )
{
AttributeTypeImpl at = ( AttributeTypeImpl ) element;
// Label
- if ( labelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_FIRST_NAME )
+ if ( labelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_FIRST_NAME )
{
String[] names = at.getNames();
if ( ( names != null ) && ( names.length > 0 ) )
@@ -89,7 +90,7 @@
label = NONE;
}
}
- else if ( labelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_ALL_ALIASES )
+ else if ( labelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_ALL_ALIASES )
{
String[] names = at.getNames();
if ( ( names != null ) && ( names.length > 0 ) )
@@ -101,7 +102,7 @@
label = NONE;
}
}
- else if ( labelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_OID )
+ else if ( labelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_OID )
{
label = at.getOid();
}
@@ -130,7 +131,7 @@
ObjectClassImpl oc = ( ObjectClassImpl ) element;
// Label
- if ( labelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_FIRST_NAME )
+ if ( labelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_FIRST_NAME )
{
String[] names = oc.getNames();
if ( ( names != null ) && ( names.length > 0 ) )
@@ -142,7 +143,7 @@
label = NONE;
}
}
- else if ( labelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_ALL_ALIASES )
+ else if ( labelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_ALL_ALIASES )
{
String[] names = oc.getNames();
if ( ( names != null ) && ( names.length > 0 ) )
@@ -154,7 +155,7 @@
label = NONE;
}
}
- else if ( labelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_OID )
+ else if ( labelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_OID )
{
label = oc.getOid();
}
@@ -178,12 +179,6 @@
label = label.substring( 0, abbreviateMaxLength ) + "..."; //$NON-NLS-1$
}
}
- else if ( element instanceof Folder )
- {
- Folder folder = ( Folder ) element;
-
- return folder.getName() + " (" + folder.getChildren().size() + ")";
- }
// Secondary Label
if ( secondaryLabelDisplay )
@@ -193,7 +188,7 @@
{
AttributeTypeImpl at = ( AttributeTypeImpl ) element;
- if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_FIRST_NAME )
+ if ( secondaryLabelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_FIRST_NAME )
{
String[] names = at.getNames();
if ( ( names != null ) && ( names.length > 0 ) )
@@ -205,7 +200,7 @@
secondaryLabel = NONE;
}
}
- else if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_ALL_ALIASES )
+ else if ( secondaryLabelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_ALL_ALIASES )
{
String[] names = at.getNames();
if ( ( names != null ) && ( names.length > 0 ) )
@@ -217,7 +212,7 @@
secondaryLabel = NONE;
}
}
- else if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_OID )
+ else if ( secondaryLabelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_OID )
{
secondaryLabel = at.getOid();
}
@@ -226,7 +221,7 @@
{
ObjectClassImpl oc = ( ObjectClassImpl ) element;
- if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_FIRST_NAME )
+ if ( secondaryLabelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_FIRST_NAME )
{
String[] names = oc.getNames();
if ( ( names != null ) && ( names.length > 0 ) )
@@ -238,7 +233,7 @@
secondaryLabel = NONE;
}
}
- else if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_ALL_ALIASES )
+ else if ( secondaryLabelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_ALL_ALIASES )
{
String[] names = oc.getNames();
if ( ( names != null ) && ( names.length > 0 ) )
@@ -250,7 +245,7 @@
secondaryLabel = NONE;
}
}
- else if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_OID )
+ else if ( secondaryLabelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_OID )
{
secondaryLabel = oc.getOid();
}
@@ -262,6 +257,17 @@
}
label += " [" + secondaryLabel + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Schema Label
+ if ( schemaLabelDisplay )
+ {
+ if ( element instanceof SchemaObject )
+ {
+ SchemaObject object = ( SchemaObject ) element;
+
+ label += " from the schema \"" + object.getSchema() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
return label;
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchViewSortingDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchViewSortingDialog.java?rev=567721&view=auto
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchViewSortingDialog.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SearchViewSortingDialog.java Mon Aug 20 07:57:37 2007
@@ -0,0 +1,254 @@
+/*
+ * 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.PluginConstants;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.SWT;
+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.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * This class implements the SearchView Sorting Dialog.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchViewSortingDialog extends Dialog
+{
+ /** The title of the dialog */
+ private static final String DIALOG_TITLE = "Search View Sorting";
+
+ /** The Sorting First Name category */
+ private static final String SORTING_FISTNAME = "First Name";
+
+ /** The Sorting OID category */
+ private static final String SORTING_OID = "OID";
+
+ // UI Fields
+ private Button attributeTypesFirst;
+ private Button objectClassesFirst;
+ private Button mixedButton;
+ private Combo sortingCombo;
+ private Button ascendingButton;
+ private Button descendingButton;
+
+
+ /**
+ * Creates a new instance of SearchViewSortingDialog.
+ *
+ * @param parentShell
+ * the parent shell
+ */
+ public SearchViewSortingDialog( Shell parentShell )
+ {
+ super( parentShell );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell( Shell newShell )
+ {
+ super.configureShell( newShell );
+ newShell.setText( DIALOG_TITLE );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea( Composite parent )
+ {
+ Composite composite = ( Composite ) super.createDialogArea( parent );
+ GridData gd = new GridData( GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL );
+ composite.setLayoutData( gd );
+
+ // Grouping Group
+ Group groupingGroup = new Group( composite, SWT.NONE );
+ groupingGroup.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ groupingGroup.setText( "Grouping" );
+ groupingGroup.setLayout( new GridLayout() );
+
+ // Attribute Types first Button
+ attributeTypesFirst = new Button( groupingGroup, SWT.RADIO );
+ attributeTypesFirst.setText( "Display attribute types first" );
+ attributeTypesFirst.setEnabled( true );
+
+ // Object Classes first Button
+ objectClassesFirst = new Button( groupingGroup, SWT.RADIO );
+ objectClassesFirst.setText( "Display object classes first" );
+ objectClassesFirst.setEnabled( true );
+
+ // Mixed Button
+ mixedButton = new Button( groupingGroup, SWT.RADIO );
+ mixedButton.setText( "Mixed" );
+ mixedButton.setEnabled( true );
+
+ // Sorting Group
+ Group sortingGroup = new Group( composite, SWT.NONE );
+ sortingGroup.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ sortingGroup.setText( "Sorting" );
+ sortingGroup.setLayout( new GridLayout() );
+ Composite sortingGroupComposite = new Composite( sortingGroup, SWT.NONE );
+ GridLayout gl = new GridLayout( 4, false );
+ gl.marginHeight = gl.marginWidth = 0;
+ sortingGroupComposite.setLayout( gl );
+ sortingGroupComposite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+ // Sort by Label
+ Label sortByLabel = new Label( sortingGroupComposite, SWT.NONE );
+ sortByLabel.setText( "Sort by" );
+
+ // Sorting Combo
+ sortingCombo = new Combo( sortingGroupComposite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER );
+ sortingCombo.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+ sortingCombo.setItems( new String[]
+ { SORTING_FISTNAME, SORTING_OID } );
+ sortingCombo.setEnabled( true );
+
+ // Ascending Button
+ ascendingButton = new Button( sortingGroupComposite, SWT.RADIO );
+ ascendingButton.setText( "Ascending" );
+ ascendingButton.setEnabled( true );
+
+ // Descending Button
+ descendingButton = new Button( sortingGroupComposite, SWT.RADIO );
+ descendingButton.setText( "Descending" );
+ descendingButton.setEnabled( true );
+
+ initFieldsFromPreferences();
+
+ applyDialogFont( composite );
+ return composite;
+ }
+
+
+ /**
+ * Initializes the fields for the stored preferences.
+ */
+ private void initFieldsFromPreferences()
+ {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+
+ int grouping = store.getInt( PluginConstants.PREFS_SEARCH_VIEW_GROUPING );
+ if ( grouping == PluginConstants.PREFS_SEARCH_VIEW_GROUPING_ATTRIBUTE_TYPES_FIRST )
+ {
+ attributeTypesFirst.setSelection( true );
+ }
+ else if ( grouping == PluginConstants.PREFS_SEARCH_VIEW_GROUPING_OBJECT_CLASSES_FIRST )
+ {
+ objectClassesFirst.setSelection( true );
+ }
+ else if ( grouping == PluginConstants.PREFS_SEARCH_VIEW_GROUPING_MIXED )
+ {
+ mixedButton.setSelection( true );
+ }
+
+ int sortingBy = store.getInt( PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY );
+ if ( sortingBy == PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY_FIRSTNAME )
+ {
+ sortingCombo.select( 0 );
+ }
+ else if ( sortingBy == PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY_OID )
+ {
+ sortingCombo.select( 1 );
+ }
+
+ int sortingOrder = store.getInt( PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER );
+ if ( sortingOrder == PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER_ASCENDING )
+ {
+ ascendingButton.setSelection( true );
+ }
+ else if ( sortingOrder == PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER_DESCENDING )
+ {
+ descendingButton.setSelection( true );
+ }
+
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+ */
+ protected void buttonPressed( int buttonId )
+ {
+ if ( buttonId == IDialogConstants.OK_ID )
+ {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ if ( ( attributeTypesFirst.getSelection() ) && ( !objectClassesFirst.getSelection() )
+ && ( !mixedButton.getSelection() ) )
+ {
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_GROUPING,
+ PluginConstants.PREFS_SEARCH_VIEW_GROUPING_ATTRIBUTE_TYPES_FIRST );
+ }
+ else if ( ( !attributeTypesFirst.getSelection() ) && ( objectClassesFirst.getSelection() )
+ && ( !mixedButton.getSelection() ) )
+ {
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_GROUPING,
+ PluginConstants.PREFS_SEARCH_VIEW_GROUPING_OBJECT_CLASSES_FIRST );
+ }
+ else if ( ( !attributeTypesFirst.getSelection() ) && ( !objectClassesFirst.getSelection() )
+ && ( mixedButton.getSelection() ) )
+ {
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_GROUPING,
+ PluginConstants.PREFS_SEARCH_VIEW_GROUPING_MIXED );
+ }
+
+ if ( sortingCombo.getItem( sortingCombo.getSelectionIndex() ).equals( SORTING_FISTNAME ) )
+ {
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY,
+ PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY_FIRSTNAME );
+ }
+ else if ( sortingCombo.getItem( sortingCombo.getSelectionIndex() ).equals( SORTING_OID ) )
+ {
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY,
+ PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY_OID );
+ }
+
+ if ( ascendingButton.getSelection() && !descendingButton.getSelection() )
+ {
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER,
+ PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER_ASCENDING );
+ }
+ else if ( !ascendingButton.getSelection() && descendingButton.getSelection() )
+ {
+ store.setValue( PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER,
+ PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER_DESCENDING );
+ }
+ }
+
+ super.buttonPressed( buttonId );
+ }
+}