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/07/18 13:22:51 UTC
svn commit: r557228 [1/2] - in
/directory/studio/trunk/studio-apacheds-schemaeditor: ./ META-INF/
resources/icons/
src/main/java/org/apache/directory/studio/apacheds/schemaeditor/
src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controll...
Author: pamarcelot
Date: Wed Jul 18 04:22:50 2007
New Revision: 557228
URL: http://svn.apache.org/viewvc?view=rev&rev=557228
Log:
Added the SchemaViewPreferencePage and the SchemaViewSortingDialog.
Added new Actions to open these new windows from the SchemaView.
Updated the ContentProvider and LabelProvider of the SchemaView.
Added:
directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/sorting.gif (with props)
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSchemaViewPreferenceAction.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSchemaViewSortingDialogAction.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/PluginPreferencePage.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/SchemaViewPreferencePage.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/wrappers/FirstNameSorter.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/OidSorter.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/SchemaSorter.java
Modified:
directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF
directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml
directory/studio/trunk/studio-apacheds-schemaeditor/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/SchemaViewController.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaView.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaViewContentProvider.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaViewLabelProvider.java
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF?view=diff&rev=557228&r1=557227&r2=557228
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF Wed Jul 18 04:22:50 2007
@@ -7,11 +7,10 @@
Bundle-Vendor: Apache Software Foundation
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
- org.apache.directory.studio.jars,
org.eclipse.core.runtime,
- org.eclipse.ui.forms,
+ org.apache.directory.studio.jars,
org.eclipse.jface.text,
- org.eclipse.core.runtime.compatibility
+ org.eclipse.ui.forms
Eclipse-LazyStart: true
Bundle-ClassPath: .,
lib/apacheds-core-plugin-1.5.0-SNAPSHOT.jar
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml?view=diff&rev=557228&r1=557227&r2=557228
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml Wed Jul 18 04:22:50 2007
@@ -173,4 +173,16 @@
name="Schema Projects">
</wizard>
</extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ class="org.apache.directory.studio.apacheds.schemaeditor.view.preferences.PluginPreferencePage"
+ id="org.apache.directory.studio.apacheds.schemaeditor.preferences.plugin"
+ name="Schema Editor"/>
+ <page
+ category="org.apache.directory.studio.apacheds.schemaeditor.view.preferences.plugin"
+ class="org.apache.directory.studio.apacheds.schemaeditor.view.preferences.SchemaViewPreferencePage"
+ id="org.apache.directory.studio.apacheds.schemaeditor.preferences.schemaView"
+ name="Schema View"/>
+ </extension>
</plugin>
Added: directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/sorting.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/sorting.gif?view=auto&rev=557228
==============================================================================
Binary file - no diff available.
Propchange: directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/sorting.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=557228&r1=557227&r2=557228
==============================================================================
--- 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 Wed Jul 18 04:22:50 2007
@@ -20,6 +20,9 @@
package org.apache.directory.studio.apacheds.schemaeditor;
+import org.apache.directory.studio.apacheds.schemaeditor.view.preferences.SchemaViewPreferencePage;
+
+
/**
* This interface contains all the Constants used in the Plugin.
*
@@ -67,6 +70,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_SORTING = "resources/icons/sorting.gif";
public static final String IMG_TOOLBAR_MENU = "resources/icons/toolbar_menu.gif";
// Commands
@@ -85,13 +89,17 @@
public static final String CMD_IMPORT_SCHEMAS_FROM_XML = Activator.PLUGIN_ID + ".commands.importSchemasFromXML";
public static final String CMD_OPEN_ELEMENT = Activator.PLUGIN_ID + ".commands.openElement";
public static final String CMD_OPEN_PROJECT = Activator.PLUGIN_ID + ".commands.openProject";
+ public static final String CMD_OPEN_SCHEMA_VIEW_PREFERENCE = Activator.PLUGIN_ID
+ + ".commands.openSchemaViewPreference";
+ public static final String CMD_OPEN_SCHEMA_VIEW_SORTING_DIALOG = Activator.PLUGIN_ID
+ + ".commands.openSchemaViewSortingDialog";
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";
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";
- // Preferences
+ // Preferences - DifferencesWidget
/** The preferences ID for DifferencesWidget Grouping */
public static final String PREFS_DIFFERENCES_WIDGET_GROUPING = Activator.PLUGIN_ID
+ ".prefs.DifferencesWidget.grouping";
@@ -100,4 +108,49 @@
/** The preference value for DifferencesWidget Grouping 'Property' */
public static final int PREFS_DIFFERENCES_WIDGET_GROUPING_TYPE = 1;
+ // Preferences - SchemaView
+ /** The preference ID for Schema View Label */
+ public static final String PREFS_SCHEMA_VIEW_LABEL = SchemaViewPreferencePage.ID + ".label.labelValue"; //$NON-NLS-1$
+ /** The preference value for Schema View First Name label */
+ public static final int PREFS_SCHEMA_VIEW_LABEL_FIRST_NAME = 0;
+ /** The preference value for Schema View All Aliases label */
+ public static final int PREFS_SCHEMA_VIEW_LABEL_ALL_ALIASES = 1;
+ /** The preference value for Schema View OID label */
+ public static final int PREFS_SCHEMA_VIEW_LABEL_OID = 2;
+ /** The preference ID for Schema View Abbreviate */
+ public static final String PREFS_SCHEMA_VIEW_ABBREVIATE = SchemaViewPreferencePage.ID + ".label.abbreviate"; //$NON-NLS-1$
+ /** The preference ID for Schema View Abbreviate Max Length*/
+ public static final String PREFS_SCHEMA_VIEW_ABBREVIATE_MAX_LENGTH = SchemaViewPreferencePage.ID
+ + ".label.abbreviate.maxLength"; //$NON-NLS-1$
+ /** The preference ID for Schema View Display Secondary Label */
+ public static final String PREFS_SCHEMA_VIEW_SECONDARY_LABEL_DISPLAY = SchemaViewPreferencePage.ID
+ + ".secondaryLabel.display"; //$NON-NLS-1$
+ /** The preference ID for Schema View Secondary Label */
+ public static final String PREFS_SCHEMA_VIEW_SECONDARY_LABEL = SchemaViewPreferencePage.ID
+ + ".secondaryLabel.labelValue"; //$NON-NLS-1$
+ /** The preference ID for Schema View Abbreviate Secondary Label */
+ public static final String PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE = SchemaViewPreferencePage.ID
+ + ".secondaryLabel.abbreviate"; //$NON-NLS-1$
+ /** The preference ID for Schema View Abbreviate Secondary Label Max Length*/
+ public static final String PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH = SchemaViewPreferencePage.ID
+ + ".secondaryLabel.abbreviate.maxLength"; //$NON-NLS-1$
+ /** The preference ID for Schema View Grouping */
+ public static final String PREFS_SCHEMA_VIEW_GROUPING = Activator.PLUGIN_ID + ".preferences.SchemaView.grouping"; //$NON-NLS-1$
+ /** The preference value for Schema View Grouping 'group ATs and OCs in folders' */
+ public static final int PREFS_SCHEMA_VIEW_GROUPING_FOLDERS = 0;
+ /** The preference value for Schema View Grouping 'mixed' */
+ public static final int PREFS_SCHEMA_VIEW_GROUPING_MIXED = 1;
+ /** The preference ID for Schema View Sorting By */
+ public static final String PREFS_SCHEMA_VIEW_SORTING_BY = Activator.PLUGIN_ID + ".preferences.SchemaView.sortingBy"; //$NON-NLS-1$
+ /** The preference value for Schema View Sorting 'First Name' */
+ public static final int PREFS_SCHEMA_VIEW_SORTING_BY_FIRSTNAME = 0;
+ /** The preference value for Schema View Sorting 'OID' */
+ public static final int PREFS_SCHEMA_VIEW_SORTING_BY_OID = 1;
+ /** The preference ID for Sorting Order */
+ public static final String PREFS_SCHEMA_VIEW_SORTING_ORDER = Activator.PLUGIN_ID
+ + ".preferences.SchemaView.sortingOrder"; //$NON-NLS-1$
+ /** The preference value for Schema View Sorting 'ascending' */
+ public static final int PREFS_SCHEMA_VIEW_SORTING_ORDER_ASCENDING = 0;
+ /** The preference value for Schema View Sorting 'descending' */
+ public static final int PREFS_SCHEMA_VIEW_SORTING_ORDER_DESCENDING = 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?view=diff&rev=557228&r1=557227&r2=557228
==============================================================================
--- 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 Wed Jul 18 04:22:50 2007
@@ -42,5 +42,15 @@
// DifferencesWidget
store.setDefault( PluginConstants.PREFS_DIFFERENCES_WIDGET_GROUPING,
PluginConstants.PREFS_DIFFERENCES_WIDGET_GROUPING_PROPERTY );
+
+ // Schema View 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$
+ store.setDefault( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_DISPLAY, true );
+ store.setDefault( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL,
+ PluginConstants.PREFS_SCHEMA_VIEW_LABEL_OID );
+ 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$
}
}
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java?view=diff&rev=557228&r1=557227&r2=557228
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java Wed Jul 18 04:22:50 2007
@@ -20,6 +20,11 @@
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;
@@ -31,6 +36,8 @@
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.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;
@@ -46,6 +53,8 @@
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;
@@ -68,6 +77,9 @@
/** The associated view */
private SchemaView view;
+ /** The authorized Preferences keys*/
+ private List<String> authorizedPrefs;
+
/** The Context Menu */
private MenuManager contextMenu;
@@ -86,6 +98,8 @@
private ExportSchemasAsOpenLdapAction exportSchemasAsOpenLdap;
private ExportSchemasAsXmlAction exportSchemasAsXml;
private CollapseAllAction collapseAll;
+ private OpenSchemaViewSortingDialogAction openSchemaViewSortingDialog;
+ private OpenSchemaViewPreferenceAction openSchemaViewPreference;
/**
@@ -101,8 +115,11 @@
initActions();
initToolbar();
+ initMenu();
initContextMenu();
initDoubleClickListener();
+ initAuthorizedPrefs();
+ initPreferencesListener();
}
@@ -122,6 +139,8 @@
exportSchemasAsOpenLdap = new ExportSchemasAsOpenLdapAction();
exportSchemasAsXml = new ExportSchemasAsXmlAction();
collapseAll = new CollapseAllAction( viewer );
+ openSchemaViewSortingDialog = new OpenSchemaViewSortingDialogAction();
+ openSchemaViewPreference = new OpenSchemaViewPreferenceAction();
}
@@ -141,6 +160,20 @@
/**
+ * Initializes the Menu.
+ */
+ private void initMenu()
+ {
+ IMenuManager menu = view.getViewSite().getActionBars().getMenuManager();
+ menu.add( openSchemaViewSortingDialog );
+ menu.add( new Separator() );
+ // menu.add( linkWithEditor );
+ // menu.add( new Separator() );
+ menu.add( openSchemaViewPreference );
+ }
+
+
+ /**
* Initializes the ContextMenu.
*/
private void initContextMenu()
@@ -232,6 +265,53 @@
{
// logger.debug( "error when opening the editor" ); //$NON-NLS-1$
e.printStackTrace();
+ }
+ }
+ }
+ } );
+ }
+
+
+ /**
+ * Initializes the Authorized Prefs IDs.
+ */
+ private void initAuthorizedPrefs()
+ {
+ authorizedPrefs = new ArrayList<String>();
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_LABEL );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_ABBREVIATE );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_ABBREVIATE_MAX_LENGTH );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_DISPLAY );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_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() ) )
+ {
+ if ( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING == event.getProperty() )
+ {
+ view.reloadViewer();
+ }
+ else
+ {
+ view.update();
}
}
}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSchemaViewPreferenceAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSchemaViewPreferenceAction.java?view=auto&rev=557228
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSchemaViewPreferenceAction.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSchemaViewPreferenceAction.java Wed Jul 18 04:22:50 2007
@@ -0,0 +1,100 @@
+/*
+ * 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.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 SchemaView.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class OpenSchemaViewPreferenceAction extends Action implements IWorkbenchWindowActionDelegate
+{
+ /**
+ * Creates a new instance of OpenSchemaViewPreferenceAction.
+ */
+ public OpenSchemaViewPreferenceAction()
+ {
+ super( "Preferences..." );
+ setToolTipText( getText() );
+ setId( PluginConstants.CMD_OPEN_SCHEMA_VIEW_PREFERENCE );
+ setEnabled( true );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run()
+ {
+ Shell shell = Display.getCurrent().getActiveShell();
+ PreferencesUtil.createPreferenceDialogOn( shell, SchemaViewPreferencePage.ID, new String[]
+ { SchemaViewPreferencePage.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/OpenSchemaViewSortingDialogAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSchemaViewSortingDialogAction.java?view=auto&rev=557228
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSchemaViewSortingDialogAction.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenSchemaViewSortingDialogAction.java Wed Jul 18 04:22:50 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.SchemaViewSortingDialog;
+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 SchemaView.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class OpenSchemaViewSortingDialogAction extends Action implements IWorkbenchWindowActionDelegate
+{
+ /**
+ * Creates a new instance of OpenSchemaViewPreferenceAction.
+ */
+ public OpenSchemaViewSortingDialogAction()
+ {
+ super( "Sorting..." );
+ setToolTipText( getText() );
+ setId( PluginConstants.CMD_OPEN_SCHEMA_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()
+ {
+ SchemaViewSortingDialog svsd = new SchemaViewSortingDialog( 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/PluginPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/PluginPreferencePage.java?view=auto&rev=557228
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/PluginPreferencePage.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/PluginPreferencePage.java Wed Jul 18 04:22:50 2007
@@ -0,0 +1,74 @@
+/*
+ * 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.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+/**
+ * This class implements the Preference page for the Plugin
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PluginPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+ /**
+ * Creates a new instance of PluginPreferencePage.
+ *
+ */
+ public PluginPreferencePage()
+ {
+ super();
+ setPreferenceStore( Activator.getDefault().getPreferenceStore() );
+ setDescription( "Please select a preference page below \"Schema Editor\"." );
+ }
+
+
+ /* (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 ) );
+
+ return parent;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init( IWorkbench workbench )
+ {
+ // Nothing to do
+ }
+}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/SchemaViewPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/SchemaViewPreferencePage.java?view=auto&rev=557228
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/SchemaViewPreferencePage.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/preferences/SchemaViewPreferencePage.java Wed Jul 18 04:22:50 2007
@@ -0,0 +1,432 @@
+/*
+ * 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 Schema View
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaViewPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+ /** The preference page ID */
+ public static final String ID = Activator.PLUGIN_ID + ".preferences.schemaView"; //$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;
+
+
+ /**
+ * Creates a new instance of SchemaViewPreferencePage.
+ */
+ public SchemaViewPreferencePage()
+ {
+ super();
+ setPreferenceStore( Activator.getDefault().getPreferenceStore() );
+ setDescription( "General settings for the Schema 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." );
+
+ 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_SCHEMA_VIEW_LABEL ) );
+ limitButton.setSelection( store.getBoolean( PluginConstants.PREFS_SCHEMA_VIEW_ABBREVIATE ) );
+ lengthText.setEnabled( limitButton.getSelection() );
+ lengthText.setText( store.getString( PluginConstants.PREFS_SCHEMA_VIEW_ABBREVIATE_MAX_LENGTH ) );
+
+ secondaryLabelButtonDisplay.setSelection( store
+ .getBoolean( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_DISPLAY ) );
+ secondaryLabelCombo.select( store.getInt( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL ) );
+ secondaryLabelLimitButton.setSelection( store
+ .getBoolean( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE ) );
+ secondaryLabelLengthText.setText( store
+ .getString( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH ) );
+ if ( store.getBoolean( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_DISPLAY ) )
+ {
+ secondaryLabelCombo.setEnabled( true );
+ secondaryLabelLimitButton.setEnabled( true );
+ secondaryLabelLengthText.setEnabled( secondaryLabelLimitButton.getSelection() );
+ }
+ else
+ {
+ secondaryLabelCombo.setEnabled( false );
+ secondaryLabelLimitButton.setEnabled( false );
+ secondaryLabelLengthText.setEnabled( false );
+ }
+ }
+
+
+ /**
+ * 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_SCHEMA_VIEW_LABEL ) );
+ limitButton.setSelection( store.getDefaultBoolean( PluginConstants.PREFS_SCHEMA_VIEW_ABBREVIATE ) );
+ lengthText.setEnabled( limitButton.getSelection() );
+ lengthText.setText( store.getDefaultString( PluginConstants.PREFS_SCHEMA_VIEW_ABBREVIATE_MAX_LENGTH ) );
+
+ secondaryLabelButtonDisplay.setSelection( store
+ .getDefaultBoolean( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_DISPLAY ) );
+ secondaryLabelCombo.select( store.getDefaultInt( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL ) );
+ secondaryLabelLimitButton.setSelection( store
+ .getDefaultBoolean( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE ) );
+ secondaryLabelLengthText.setText( store
+ .getDefaultString( PluginConstants.PREFS_SCHEMA_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 );
+ }
+
+ 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_SCHEMA_VIEW_LABEL, PluginConstants.PREFS_SCHEMA_VIEW_LABEL_FIRST_NAME );
+ }
+ else if ( labelCombo.getItem( labelCombo.getSelectionIndex() ).equals( ALL_ALIASES ) )
+ {
+ store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_LABEL,
+ PluginConstants.PREFS_SCHEMA_VIEW_LABEL_ALL_ALIASES );
+ }
+ else if ( labelCombo.getItem( labelCombo.getSelectionIndex() ).equals( OID ) )
+ {
+ store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_LABEL, PluginConstants.PREFS_SCHEMA_VIEW_LABEL_OID );
+ }
+ store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_ABBREVIATE, limitButton.getSelection() );
+ store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_ABBREVIATE_MAX_LENGTH, lengthText.getText() );
+
+ store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_DISPLAY, secondaryLabelButtonDisplay
+ .getSelection() );
+ if ( secondaryLabelCombo.getItem( secondaryLabelCombo.getSelectionIndex() ).equals( FIRST_NAME ) )
+ {
+ store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL,
+ PluginConstants.PREFS_SCHEMA_VIEW_LABEL_FIRST_NAME );
+ }
+ else if ( secondaryLabelCombo.getItem( secondaryLabelCombo.getSelectionIndex() ).equals( ALL_ALIASES ) )
+ {
+ store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL,
+ PluginConstants.PREFS_SCHEMA_VIEW_LABEL_ALL_ALIASES );
+ }
+ else if ( secondaryLabelCombo.getItem( secondaryLabelCombo.getSelectionIndex() ).equals( OID ) )
+ {
+ store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL,
+ PluginConstants.PREFS_SCHEMA_VIEW_LABEL_OID );
+ }
+ store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE, secondaryLabelLimitButton
+ .getSelection() );
+ store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH,
+ secondaryLabelLengthText.getText() );
+
+ 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/SchemaView.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaView.java?view=diff&rev=557228&r1=557227&r2=557228
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaView.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaView.java Wed Jul 18 04:22:50 2007
@@ -112,7 +112,7 @@
private void initViewer( Composite parent )
{
treeViewer = new TreeViewer( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER );
- contentProvider = new SchemaViewContentProvider( treeViewer );
+ contentProvider = new SchemaViewContentProvider();
treeViewer.setContentProvider( contentProvider );
treeViewer.setLabelProvider( new DecoratingLabelProvider( new SchemaViewLabelProvider(), Activator.getDefault()
.getWorkbench().getDecoratorManager().getLabelDecorator() ) );
@@ -146,5 +146,14 @@
public void reloadViewer()
{
treeViewer.setInput( new SchemaViewRoot() );
+ }
+
+
+ /**
+ * Updates the viewer
+ */
+ public void update()
+ {
+ treeViewer.update( treeViewer.getInput(), null );
}
}
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaViewContentProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaViewContentProvider.java?view=diff&rev=557228&r1=557227&r2=557228
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaViewContentProvider.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaViewContentProvider.java Wed Jul 18 04:22:50 2007
@@ -20,22 +20,29 @@
package org.apache.directory.studio.apacheds.schemaeditor.view.views;
+import java.util.ArrayList;
+import java.util.Collections;
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.SchemaHandler;
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.Schema;
import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.AttributeTypeWrapper;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.FirstNameSorter;
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.OidSorter;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.SchemaSorter;
import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.SchemaViewRoot;
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.preference.IPreferenceStore;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
@@ -47,19 +54,29 @@
*/
public class SchemaViewContentProvider implements IStructuredContentProvider, ITreeContentProvider
{
- /** The associated viewer */
- private TreeViewer viewer;
+ /** The preferences store */
+ private IPreferenceStore store;
+
+ /** The FirstName Sorter */
+ private FirstNameSorter firstNameSorter;
+
+ /** The OID Sorter */
+ private OidSorter oidSorter;
+
+ /** The Schema Sorter */
+ private SchemaSorter schemaSorter;
/**
- * Default constructor
- *
- * @param viewer
- * the associated TreeViewer
+ * Creates a new instance of SchemaViewContentProvider.
*/
- public SchemaViewContentProvider( TreeViewer viewer )
+ public SchemaViewContentProvider()
{
- this.viewer = viewer;
+ store = Activator.getDefault().getPreferenceStore();
+
+ firstNameSorter = new FirstNameSorter();
+ oidSorter = new OidSorter();
+ schemaSorter = new SchemaSorter();
}
@@ -95,7 +112,11 @@
*/
public Object[] getChildren( Object parentElement )
{
- List<TreeNode> children = null;
+ List<TreeNode> children = new ArrayList<TreeNode>();
+
+ int group = store.getInt( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING );
+ int sortBy = store.getInt( PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY );
+ int sortOrder = store.getInt( PluginConstants.PREFS_SCHEMA_VIEW_SORTING_ORDER );
if ( parentElement instanceof SchemaViewRoot )
{
@@ -103,40 +124,98 @@
if ( root.getChildren().isEmpty() )
{
- List<Schema> schemas = Activator.getDefault().getSchemaHandler().getSchemas();
- for ( Schema schema : schemas )
+ SchemaHandler schemaHandler = Activator.getDefault().getSchemaHandler();
+ if ( schemaHandler != null )
{
- SchemaWrapper schemaWrapper = new SchemaWrapper( schema, root );
- root.addChild( schemaWrapper );
-
- Folder atFolder = new Folder( FolderType.ATTRIBUTE_TYPE, schemaWrapper );
- schemaWrapper.addChild( atFolder );
- Folder ocFolder = new Folder( FolderType.OBJECT_CLASS, schemaWrapper );
- schemaWrapper.addChild( ocFolder );
-
- List<AttributeTypeImpl> attributeTypes = schema.getAttributeTypes();
- for ( AttributeTypeImpl attributeType : attributeTypes )
+ List<Schema> schemas = schemaHandler.getSchemas();
+ for ( Schema schema : schemas )
{
- atFolder.addChild( new AttributeTypeWrapper( attributeType, atFolder ) );
- }
+ SchemaWrapper schemaWrapper = new SchemaWrapper( schema, root );
+ root.addChild( schemaWrapper );
- List<ObjectClassImpl> objectClasses = schema.getObjectClasses();
- for ( ObjectClassImpl objectClass : objectClasses )
- {
- ocFolder.addChild( new ObjectClassWrapper( objectClass, ocFolder ) );
+ if ( group == PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_FOLDERS )
+ {
+ Folder atFolder = new Folder( FolderType.ATTRIBUTE_TYPE, schemaWrapper );
+ schemaWrapper.addChild( atFolder );
+ Folder ocFolder = new Folder( FolderType.OBJECT_CLASS, schemaWrapper );
+ schemaWrapper.addChild( ocFolder );
+
+ List<AttributeTypeImpl> attributeTypes = schema.getAttributeTypes();
+ for ( AttributeTypeImpl attributeType : attributeTypes )
+ {
+ atFolder.addChild( new AttributeTypeWrapper( attributeType, atFolder ) );
+ }
+
+ List<ObjectClassImpl> objectClasses = schema.getObjectClasses();
+ for ( ObjectClassImpl objectClass : objectClasses )
+ {
+ ocFolder.addChild( new ObjectClassWrapper( objectClass, ocFolder ) );
+ }
+ }
+ else if ( group == PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_MIXED )
+ {
+ List<AttributeTypeImpl> attributeTypes = schema.getAttributeTypes();
+ for ( AttributeTypeImpl attributeType : attributeTypes )
+ {
+ schemaWrapper.addChild( new AttributeTypeWrapper( attributeType, schemaWrapper ) );
+ }
+
+ List<ObjectClassImpl> objectClasses = schema.getObjectClasses();
+ for ( ObjectClassImpl objectClass : objectClasses )
+ {
+ schemaWrapper.addChild( new ObjectClassWrapper( objectClass, schemaWrapper ) );
+ }
+ }
}
}
}
children = root.getChildren();
+
+ Collections.sort( children, schemaSorter );
}
else if ( parentElement instanceof SchemaWrapper )
{
children = ( ( SchemaWrapper ) parentElement ).getChildren();
+
+ if ( group == PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_MIXED )
+ {
+ // Sort by
+ if ( sortBy == PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY_FIRSTNAME )
+ {
+ Collections.sort( children, firstNameSorter );
+ }
+ else if ( sortBy == PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY_OID )
+ {
+ Collections.sort( children, oidSorter );
+ }
+
+ // Sort Order
+ if ( sortOrder == PluginConstants.PREFS_SCHEMA_VIEW_SORTING_ORDER_DESCENDING )
+ {
+ Collections.reverse( children );
+ }
+ }
}
else if ( parentElement instanceof Folder )
{
children = ( ( Folder ) parentElement ).getChildren();
+
+ // Sort by
+ if ( sortBy == PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY_FIRSTNAME )
+ {
+ Collections.sort( children, firstNameSorter );
+ }
+ else if ( sortBy == PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY_OID )
+ {
+ Collections.sort( children, oidSorter );
+ }
+
+ // Sort Order
+ if ( sortOrder == PluginConstants.PREFS_SCHEMA_VIEW_SORTING_ORDER_DESCENDING )
+ {
+ Collections.reverse( children );
+ }
}
return children.toArray();
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaViewLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaViewLabelProvider.java?view=diff&rev=557228&r1=557227&r2=557228
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaViewLabelProvider.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaViewLabelProvider.java Wed Jul 18 04:22:50 2007
@@ -22,10 +22,14 @@
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.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.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -39,11 +43,38 @@
*/
public class SchemaViewLabelProvider extends LabelProvider
{
+ private static final String NONE = "(None)";
+
+ /** The preferences store */
+ private IPreferenceStore store;
+
+
+ /**
+ * Creates a new instance of SchemaViewLabelProvider.
+ */
+ public SchemaViewLabelProvider()
+ {
+ store = Activator.getDefault().getPreferenceStore();
+ }
+
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
public String getText( Object element )
{
+ 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 );
+ boolean secondaryLabelAbbreviate = store
+ .getBoolean( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE );
+ int secondaryLabelAbbreviateMaxLength = store
+ .getInt( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH );
+
if ( element instanceof SchemaWrapper )
{
SchemaWrapper sw = ( SchemaWrapper ) element;
@@ -52,15 +83,109 @@
}
else if ( element instanceof AttributeTypeWrapper )
{
- AttributeTypeWrapper atw = ( AttributeTypeWrapper ) element;
+ AttributeTypeImpl at = ( ( AttributeTypeWrapper ) element ).getAttributeType();
+
+ // Label
+ if ( labelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_FIRST_NAME )
+ {
+ String[] names = at.getNames();
+ if ( ( names != null ) && ( names.length > 0 ) )
+ {
+ label = names[0];
+ }
+ else
+ {
+ label = NONE;
+ }
+ }
+ else if ( labelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_ALL_ALIASES )
+ {
+ String[] names = at.getNames();
+ if ( ( names != null ) && ( names.length > 0 ) )
+ {
+ label = ViewUtils.concateAliases( names );
+ }
+ else
+ {
+ label = NONE;
+ }
+ }
+ else if ( labelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_OID )
+ {
+ label = at.getOid();
+ }
+ else
+ // Default
+ {
+ String[] names = at.getNames();
+ if ( ( names != null ) && ( names.length > 0 ) )
+ {
+ label = names[0];
+ }
+ else
+ {
+ label = NONE;
+ }
+ }
- return atw.getAttributeType().getOid();
+ // Abbreviate
+ if ( abbreviate && ( abbreviateMaxLength < label.length() ) )
+ {
+ label = label.substring( 0, abbreviateMaxLength ) + "..."; //$NON-NLS-1$
+ }
}
else if ( element instanceof ObjectClassWrapper )
{
- ObjectClassWrapper ocw = ( ObjectClassWrapper ) element;
+ ObjectClassImpl oc = ( ( ObjectClassWrapper ) element ).getObjectClass();
- return ocw.getObjectClass().getOid();
+ // Label
+ if ( labelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_FIRST_NAME )
+ {
+ String[] names = oc.getNames();
+ if ( ( names != null ) && ( names.length > 0 ) )
+ {
+ label = names[0];
+ }
+ else
+ {
+ label = NONE;
+ }
+ }
+ else if ( labelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_ALL_ALIASES )
+ {
+ String[] names = oc.getNames();
+ if ( ( names != null ) && ( names.length > 0 ) )
+ {
+ label = ViewUtils.concateAliases( names );
+ }
+ else
+ {
+ label = NONE;
+ }
+ }
+ else if ( labelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_OID )
+ {
+ label = oc.getOid();
+ }
+ else
+ // Default
+ {
+ String[] names = oc.getNames();
+ if ( ( names != null ) && ( names.length > 0 ) )
+ {
+ label = names[0];
+ }
+ else
+ {
+ label = NONE;
+ }
+ }
+
+ // Abbreviate
+ if ( abbreviate && ( abbreviateMaxLength < label.length() ) )
+ {
+ label = label.substring( 0, abbreviateMaxLength ) + "..."; //$NON-NLS-1$
+ }
}
else if ( element instanceof Folder )
{
@@ -69,8 +194,86 @@
return folder.getName() + " (" + folder.getChildren().size() + ")";
}
- // Default
- return element.toString();
+ // Secondary Label
+ if ( secondaryLabelDisplay )
+ {
+ String secondaryLabel = ""; //$NON-NLS-1$
+ if ( element instanceof AttributeTypeWrapper )
+ {
+ AttributeTypeImpl at = ( ( AttributeTypeWrapper ) element ).getAttributeType();
+
+ if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_FIRST_NAME )
+ {
+ String[] names = at.getNames();
+ if ( ( names != null ) && ( names.length > 0 ) )
+ {
+ secondaryLabel = names[0];
+ }
+ else
+ {
+ secondaryLabel = NONE;
+ }
+ }
+ else if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_ALL_ALIASES )
+ {
+ String[] names = at.getNames();
+ if ( ( names != null ) && ( names.length > 0 ) )
+ {
+ secondaryLabel = ViewUtils.concateAliases( names );
+ }
+ else
+ {
+ secondaryLabel = NONE;
+ }
+ }
+ else if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_OID )
+ {
+ secondaryLabel = at.getOid();
+ }
+ }
+ else if ( element instanceof ObjectClassWrapper )
+ {
+ ObjectClassImpl oc = ( ( ObjectClassWrapper ) element ).getObjectClass();
+
+ if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_FIRST_NAME )
+ {
+ String[] names = oc.getNames();
+ if ( ( names != null ) && ( names.length > 0 ) )
+ {
+ secondaryLabel = names[0];
+ }
+ else
+ {
+ secondaryLabel = NONE;
+ }
+ }
+ else if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_ALL_ALIASES )
+ {
+ String[] names = oc.getNames();
+ if ( ( names != null ) && ( names.length > 0 ) )
+ {
+ secondaryLabel = ViewUtils.concateAliases( names );
+ }
+ else
+ {
+ secondaryLabel = NONE;
+ }
+ }
+ else if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_OID )
+ {
+ secondaryLabel = oc.getOid();
+ }
+ }
+
+ if ( secondaryLabelAbbreviate && ( secondaryLabelAbbreviateMaxLength < secondaryLabel.length() ) )
+ {
+ secondaryLabel = secondaryLabel.substring( 0, secondaryLabelAbbreviateMaxLength ) + "..."; //$NON-NLS-1$
+ }
+
+ label += " [" + secondaryLabel + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ return label;
}
@@ -97,18 +300,18 @@
else if ( element instanceof Folder )
{
Folder folder = ( Folder ) element;
-
+
switch ( folder.getType() )
{
case ATTRIBUTE_TYPE:
- return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_FOLDER_AT )
- .createImage();
+ return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ PluginConstants.IMG_FOLDER_AT ).createImage();
case OBJECT_CLASS:
- return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_FOLDER_OC )
- .createImage();
+ return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ PluginConstants.IMG_FOLDER_OC ).createImage();
case NONE:
return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_FOLDER )
- .createImage();
+ .createImage();
}
}
Added: 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?view=auto&rev=557228
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaViewSortingDialog.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/SchemaViewSortingDialog.java Wed Jul 18 04:22:50 2007
@@ -0,0 +1,237 @@
+/*
+ * 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 SchemaView Sorting Dialog.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaViewSortingDialog extends Dialog
+{
+ /** The title of the dialog */
+ private static final String DIALOG_TITLE = "Schema 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 inFoldersButton;
+ private Button mixedButton;
+ private Combo sortingCombo;
+ private Button ascendingButton;
+ private Button descendingButton;
+
+
+ /**
+ * Creates a new instance of SchemasViewSorterDialog.
+ *
+ * @param parentShell
+ * the parent shell
+ */
+ public SchemaViewSortingDialog( 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 );
+ // gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+ 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
+ inFoldersButton = new Button( groupingGroup, SWT.RADIO );
+ inFoldersButton.setText( "Group attribute types and object classes in folders" );
+ inFoldersButton.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_SCHEMA_VIEW_GROUPING );
+ if ( grouping == PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_FOLDERS )
+ {
+ inFoldersButton.setSelection( true );
+ }
+ else if ( grouping == PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_MIXED )
+ {
+ mixedButton.setSelection( true );
+ }
+
+ int sortingBy = store.getInt( PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY );
+ if ( sortingBy == PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY_FIRSTNAME )
+ {
+ sortingCombo.select( 0 );
+ }
+ else if ( sortingBy == PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY_OID )
+ {
+ sortingCombo.select( 1 );
+ }
+
+ int sortingOrder = store.getInt( PluginConstants.PREFS_SCHEMA_VIEW_SORTING_ORDER );
+ if ( sortingOrder == PluginConstants.PREFS_SCHEMA_VIEW_SORTING_ORDER_ASCENDING )
+ {
+ ascendingButton.setSelection( true );
+ }
+ else if ( sortingOrder == PluginConstants.PREFS_SCHEMA_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 ( ( inFoldersButton.getSelection() ) & ( !mixedButton.getSelection() ) )
+ {
+ store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING,
+ PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_FOLDERS );
+ }
+ else if ( ( !inFoldersButton.getSelection() ) & ( mixedButton.getSelection() ) )
+ {
+ store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING,
+ PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_MIXED );
+ }
+
+ if ( sortingCombo.getItem( sortingCombo.getSelectionIndex() ).equals( SORTING_FISTNAME ) )
+ {
+ store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY,
+ PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY_FIRSTNAME );
+ }
+ else if ( sortingCombo.getItem( sortingCombo.getSelectionIndex() ).equals( SORTING_OID ) )
+ {
+ store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY,
+ PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY_OID );
+ }
+
+ if ( ascendingButton.getSelection() && !descendingButton.getSelection() )
+ {
+ store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_SORTING_ORDER,
+ PluginConstants.PREFS_SCHEMA_VIEW_SORTING_ORDER_ASCENDING );
+ }
+ else if ( !ascendingButton.getSelection() && descendingButton.getSelection() )
+ {
+ store.setValue( PluginConstants.PREFS_SCHEMA_VIEW_SORTING_ORDER,
+ PluginConstants.PREFS_SCHEMA_VIEW_SORTING_ORDER_DESCENDING );
+ }
+ }
+
+ super.buttonPressed( buttonId );
+ }
+}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/FirstNameSorter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/FirstNameSorter.java?view=auto&rev=557228
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/FirstNameSorter.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/FirstNameSorter.java Wed Jul 18 04:22:50 2007
@@ -0,0 +1,96 @@
+/*
+ * 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.wrappers;
+
+
+import java.util.Comparator;
+
+import org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
+
+
+/**
+ * This class is used to compare and sort ascending two TreeNode.
+ */
+public class FirstNameSorter implements Comparator<TreeNode>
+{
+ /* (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare( TreeNode o1, TreeNode o2 )
+ {
+ String[] o1Names = null;
+ String[] o2Names = null;
+
+ if ( ( o1 instanceof AttributeTypeWrapper ) && ( o2 instanceof AttributeTypeWrapper ) )
+ {
+ AttributeTypeImpl at1 = ( ( AttributeTypeWrapper ) o1 ).getAttributeType();
+ AttributeTypeImpl at2 = ( ( AttributeTypeWrapper ) o2 ).getAttributeType();
+
+ o1Names = at1.getNames();
+ o2Names = at2.getNames();
+ }
+ else if ( ( o1 instanceof ObjectClassWrapper ) && ( o2 instanceof ObjectClassWrapper ) )
+ {
+ ObjectClassImpl oc1 = ( ( ObjectClassWrapper ) o1 ).getObjectClass();
+ ObjectClassImpl oc2 = ( ( ObjectClassWrapper ) o2 ).getObjectClass();
+
+ o1Names = oc1.getNames();
+ o2Names = oc2.getNames();
+ }
+ else if ( ( o1 instanceof AttributeTypeWrapper ) && ( o2 instanceof ObjectClassWrapper ) )
+ {
+ AttributeTypeImpl at = ( ( AttributeTypeWrapper ) o1 ).getAttributeType();
+ ObjectClassImpl oc = ( ( ObjectClassWrapper ) o2 ).getObjectClass();
+
+ o1Names = at.getNames();
+ o2Names = oc.getNames();
+ }
+ else if ( ( o1 instanceof ObjectClassWrapper ) && ( o2 instanceof AttributeTypeWrapper ) )
+ {
+ ObjectClassImpl oc = ( ( ObjectClassWrapper ) o1 ).getObjectClass();
+ AttributeTypeImpl at = ( ( AttributeTypeWrapper ) o2 ).getAttributeType();
+
+ 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() );
+ }
+}