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 2009/08/11 18:24:56 UTC
svn commit: r803187 - in /directory/studio/trunk/ldapbrowser-ui: ./
src/main/java/org/apache/directory/studio/entryeditors/
src/main/java/org/apache/directory/studio/ldapbrowser/ui/
src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/prefe...
Author: pamarcelot
Date: Tue Aug 11 16:24:56 2009
New Revision: 803187
URL: http://svn.apache.org/viewvc?rev=803187&view=rev
Log:
DIRSTUDIO-516:
o Added an EntryEditorManager for managing the entry editors.
o Added a new EntryEditorsPreferencePage that will allow the user to re-define the order of the various entry editors.
Added:
directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java
directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/EntryEditorsPreferencePage.java
Modified:
directory/studio/trunk/ldapbrowser-ui/plugin.properties
directory/studio/trunk/ldapbrowser-ui/plugin.xml
directory/studio/trunk/ldapbrowser-ui/plugin_de.properties
directory/studio/trunk/ldapbrowser-ui/plugin_fr.properties
directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIPlugin.java
Modified: directory/studio/trunk/ldapbrowser-ui/plugin.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/plugin.properties?rev=803187&r1=803186&r2=803187&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/plugin.properties (original)
+++ directory/studio/trunk/ldapbrowser-ui/plugin.properties Tue Aug 11 16:24:56 2009
@@ -115,6 +115,9 @@
PrefPage_SearchLogsPreferencePage_id=org.apache.directory.studio.ldapbrowser.preferences.SearchLogsPreferencePage
PrefPage_SearchLogsPreferencePage_name=Search Logs
+PrefPage_EntryEditorsPreferencePage_id=org.apache.directory.studio.ldapbrowser.preferences.EntryEditorsPreferencePage
+PrefPage_EntryEditorsPreferencePage_name=Entry Editors
+
Prop_ConnectionPropertyPage_id=org.apache.directory.studio.connection.ui.properties.ConnectionPropertyPage
PropPage_Schema_id=org.apache.directory.studio.ldapbrowser.ui.dialogs.properties.SchemaPropertyPage
Modified: directory/studio/trunk/ldapbrowser-ui/plugin.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/plugin.xml?rev=803187&r1=803186&r2=803187&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/plugin.xml (original)
+++ directory/studio/trunk/ldapbrowser-ui/plugin.xml Tue Aug 11 16:24:56 2009
@@ -264,6 +264,13 @@
name="%PrefPage_SearchLogsPreferencePage_name">
<keywordReference id="%Keyword_LDAP_id"/>
</page>
+ <page
+ category="%PrefPage_MainPreferencePage_id"
+ class="org.apache.directory.studio.ldapbrowser.ui.dialogs.preferences.EntryEditorsPreferencePage"
+ id="%PrefPage_EntryEditorsPreferencePage_id"
+ name="%PrefPage_EntryEditorsPreferencePage_name">
+ <keywordReference id="%Keyword_LDAP_id"/>
+ </page>
</extension>
<extension
@@ -402,9 +409,6 @@
style="push"/>
</actionSet>
</extension>
-
-
-
<extension
point="org.eclipse.ui.decorators">
<decorator
Modified: directory/studio/trunk/ldapbrowser-ui/plugin_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/plugin_de.properties?rev=803187&r1=803186&r2=803187&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/plugin_de.properties (original)
+++ directory/studio/trunk/ldapbrowser-ui/plugin_de.properties Tue Aug 11 16:24:56 2009
@@ -64,6 +64,8 @@
PrefPage_SearchLogsPreferencePage_name=Such-Logs
+PrefPage_EntryEditorsPreferencePage_name=TODO:Entry Editors
+
PropPage_Search_name=Suche
PropPage_Entry_name=Eintrag
Modified: directory/studio/trunk/ldapbrowser-ui/plugin_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/plugin_fr.properties?rev=803187&r1=803186&r2=803187&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/plugin_fr.properties (original)
+++ directory/studio/trunk/ldapbrowser-ui/plugin_fr.properties Tue Aug 11 16:24:56 2009
@@ -55,6 +55,7 @@
PrefPage_SearchResultEditorPreferencePage_name=Editeur de recherche
PrefPage_ModificationLogsPreferencePage_name=Logs de modification
PrefPage_SearchLogsPreferencePage_name=Logs de recherche
+PrefPage_EntryEditorsPreferencePage_name=Editeur d'entr\u00E9e
PropPage_Schema_name=Sch\u00E9ma
PropPage_RootDSE_name=Root DSE
Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java?rev=803187&view=auto
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java (added)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java Tue Aug 11 16:24:56 2009
@@ -0,0 +1,117 @@
+/*
+ * 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.entryeditors;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * A EntryEditorManager is used to manage entry editors. It provides methods to get
+ * the best or alternative entry editors for a given entry.
+ *
+ * The available value editors are specified by the extension point
+ * <code>org.apache.directory.studio.entryeditors</code>.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class EntryEditorManager
+{
+ private static final String ID_ATTR = "id"; //$NON-NLS-1$
+ private static final String NAME_ATTR = "name"; //$NON-NLS-1$
+ private static final String DESCRIPTION_ATTR = "description"; //$NON-NLS-1$
+ private static final String ICON_ATTR = "icon"; //$NON-NLS-1$
+ private static final String CLASS_ATTR = "class"; //$NON-NLS-1$
+ private static final String EDITOR_ID_ATTR = "editorId"; //$NON-NLS-1$
+ private static final String MULTI_WINDOW_ATTR = "multiWindow"; //$NON-NLS-1$
+ private static final String PRIORITY_ATTR = "priority"; //$NON-NLS-1$
+
+ private Collection<EntryEditorExtension> entryEditorExtensions = new ArrayList<EntryEditorExtension>();
+
+
+ /**
+ * Creates a new instance of EntryEditorManager.
+ */
+ public EntryEditorManager()
+ {
+ initEntryEditorExtensions();
+ }
+
+
+ /**
+ * Initializes the entry editors extensions.
+ */
+ private void initEntryEditorExtensions()
+ {
+ entryEditorExtensions = new ArrayList<EntryEditorExtension>();
+
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry.getExtensionPoint( BrowserUIConstants.ENTRY_EDITOR_EXTENSION_POINT );
+ IConfigurationElement[] members = extensionPoint.getConfigurationElements();
+
+ // For each extension:
+ for ( int m = 0; m < members.length; m++ )
+ {
+ EntryEditorExtension bean = new EntryEditorExtension();
+ entryEditorExtensions.add( bean );
+
+ IConfigurationElement member = members[m];
+ IExtension extension = member.getDeclaringExtension();
+ String extendingPluginId = extension.getNamespaceIdentifier();
+
+ bean.setId( member.getAttribute( ID_ATTR ) );
+ bean.setName( member.getAttribute( NAME_ATTR ) );
+ bean.setDescription( member.getAttribute( DESCRIPTION_ATTR ) );
+ String iconPath = member.getAttribute( ICON_ATTR );
+ ImageDescriptor icon = AbstractUIPlugin.imageDescriptorFromPlugin( extendingPluginId, iconPath );
+ if ( icon == null )
+ {
+ icon = ImageDescriptor.getMissingImageDescriptor();
+ }
+ bean.setIcon( icon );
+ bean.setClassName( member.getAttribute( CLASS_ATTR ) );
+ bean.setEditorId( member.getAttribute( EDITOR_ID_ATTR ) );
+ bean.setMultiWindow( "true".equalsIgnoreCase( member.getAttribute( MULTI_WINDOW_ATTR ) ) );
+ bean.setPriority( Integer.parseInt( member.getAttribute( PRIORITY_ATTR ) ) );
+ }
+ }
+
+
+ /**
+ * Gets the entry editor extensions.
+ *
+ * @return the entry editor extensions
+ */
+ public Collection<EntryEditorExtension> getEntryEditorExtensions()
+ {
+ return entryEditorExtensions;
+ }
+}
Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIPlugin.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIPlugin.java?rev=803187&r1=803186&r2=803187&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIPlugin.java (original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIPlugin.java Tue Aug 11 16:24:56 2009
@@ -23,18 +23,13 @@
import java.io.IOException;
import java.net.URL;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.PropertyResourceBundle;
import org.apache.directory.studio.entryeditors.EntryEditorExtension;
+import org.apache.directory.studio.entryeditors.EntryEditorManager;
import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
@@ -50,6 +45,9 @@
/** The shared instance */
private static BrowserUIPlugin plugin;
+ /** The entry editor manager */
+ private EntryEditorManager entryEditorManager;
+
/** The plugin properties */
private PropertyResourceBundle properties;
@@ -70,8 +68,13 @@
{
super.start( context );
+ if ( entryEditorManager == null )
+ {
+ entryEditorManager = new EntryEditorManager();
+ }
+
// TODO: remove
- Collection<EntryEditorExtension> entryEditorExtensions = getEntryEditorExtensions();
+ Collection<EntryEditorExtension> entryEditorExtensions = entryEditorManager.getEntryEditorExtensions();
System.out.println( "Registered Entry Editors:" + entryEditorExtensions.size() );
for ( EntryEditorExtension entryEditorExtension : entryEditorExtensions )
{
@@ -86,6 +89,12 @@
public void stop( BundleContext context ) throws Exception
{
super.stop( context );
+
+ if ( entryEditorManager != null )
+ {
+ entryEditorManager = null;
+ }
+
plugin = null;
}
@@ -167,6 +176,18 @@
/**
+ * Gets the entry editor manager
+ *
+ * @return
+ * the entry editor manager
+ */
+ public EntryEditorManager getEntryEditorManager()
+ {
+ return entryEditorManager;
+ }
+
+
+ /**
* Gets the plugin properties.
*
* @return
@@ -192,48 +213,4 @@
return properties;
}
-
-
- /**
- * Gets the entry editor extensions.
- *
- * @return the entry editor extensions
- */
- public Collection<EntryEditorExtension> getEntryEditorExtensions()
- {
- Collection<EntryEditorExtension> entryEditorExtensions = new ArrayList<EntryEditorExtension>();
-
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = registry.getExtensionPoint( BrowserUIConstants.ENTRY_EDITOR_EXTENSION_POINT );
- IConfigurationElement[] members = extensionPoint.getConfigurationElements();
-
- // For each extension:
- for ( int m = 0; m < members.length; m++ )
- {
- EntryEditorExtension bean = new EntryEditorExtension();
- entryEditorExtensions.add( bean );
-
- IConfigurationElement member = members[m];
- IExtension extension = member.getDeclaringExtension();
- String extendingPluginId = extension.getNamespaceIdentifier();
-
- //proxy.member = member;
- bean.setId( member.getAttribute( "id" ) );
- bean.setName( member.getAttribute( "name" ) );
- bean.setDescription( member.getAttribute( "description" ) );
- String iconPath = member.getAttribute( "icon" );
- ImageDescriptor icon = AbstractUIPlugin.imageDescriptorFromPlugin( extendingPluginId, iconPath );
- if ( icon == null )
- {
- icon = ImageDescriptor.getMissingImageDescriptor();
- }
- bean.setIcon( icon );
- bean.setClassName( member.getAttribute( "class" ) );
- bean.setEditorId( member.getAttribute( "editorId" ) );
- bean.setMultiWindow( "true".equalsIgnoreCase( member.getAttribute( "multiWindow" ) ) );
- bean.setPriority( Integer.parseInt( member.getAttribute( "priority" ) ) );
- }
-
- return entryEditorExtensions;
- }
}
Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/EntryEditorsPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/EntryEditorsPreferencePage.java?rev=803187&view=auto
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/EntryEditorsPreferencePage.java (added)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/EntryEditorsPreferencePage.java Tue Aug 11 16:24:56 2009
@@ -0,0 +1,176 @@
+/*
+ * 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.ldapbrowser.ui.dialogs.preferences;
+
+
+import org.apache.directory.studio.entryeditors.EntryEditorExtension;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+/**
+ * The entry editors preference page contains settings
+ * for the Entry Editors.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class EntryEditorsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+ // UI fields
+ private TableViewer entryEditorsTableViewer;
+ private Button upButton;
+ private Button downButton;
+
+
+ /**
+ * Creates a new instance of EntryEditorsPreferencePage.
+ */
+ public EntryEditorsPreferencePage()
+ {
+ super( "Entry Editors" );
+ super.setPreferenceStore( BrowserUIPlugin.getDefault().getPreferenceStore() );
+ super.setDescription( "Description" );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void init( IWorkbench workbench )
+ {
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ 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 ) );
+
+ // Entry Editors Label
+ Label entryEditorsLabel = new Label( composite, SWT.NONE );
+ entryEditorsLabel.setText( "Entry Editors:" );
+
+ // Entry Editors Composite
+ Composite entryEditorsComposite = new Composite( composite, SWT.NONE );
+ GridLayout gl = new GridLayout( 2, false );
+ gl.marginHeight = gl.marginWidth = 0;
+ entryEditorsComposite.setLayout( gl );
+ entryEditorsComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // SchemaConnectors TableViewer
+ entryEditorsTableViewer = new TableViewer( entryEditorsComposite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION );
+ GridData gridData = new GridData( SWT.FILL, SWT.NONE, true, false, 1, 2 );
+ gridData.heightHint = 125;
+ entryEditorsTableViewer.getTable().setLayoutData( gridData );
+ entryEditorsTableViewer.setContentProvider( new ArrayContentProvider() );
+ entryEditorsTableViewer.setLabelProvider( new LabelProvider()
+ {
+ public String getText( Object element )
+ {
+ return ( ( EntryEditorExtension ) element ).getName();
+ }
+
+
+ public Image getImage( Object element )
+ {
+ return ( ( EntryEditorExtension ) element ).getIcon().createImage();
+ }
+ } );
+
+ entryEditorsTableViewer.setInput( BrowserUIPlugin.getDefault().getEntryEditorManager()
+ .getEntryEditorExtensions() );
+
+ // Up Button
+ upButton = new Button( entryEditorsComposite, SWT.PUSH );
+ upButton.setText( "Up" );
+ upButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+ // Down Button
+ downButton = new Button( entryEditorsComposite, SWT.PUSH );
+ downButton.setText( "Down" );
+ downButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+ // Description Label
+ Label descriptionLabel = new Label( composite, SWT.NONE );
+ descriptionLabel.setText( "Description:" );
+
+ // Description Text
+ final Text descriptionText = new Text( composite, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY );
+ gridData = new GridData( SWT.FILL, SWT.NONE, true, false );
+ gridData.heightHint = 27;
+ descriptionText.setLayoutData( gridData );
+
+ entryEditorsTableViewer.addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ EntryEditorExtension schemaConnector = ( EntryEditorExtension ) ( ( StructuredSelection ) entryEditorsTableViewer
+ .getSelection() ).getFirstElement();
+
+ if ( schemaConnector != null )
+ {
+ descriptionText.setText( schemaConnector.getDescription() );
+ }
+ }
+ } );
+
+ return parent;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean performOk()
+ {
+ return true;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void performDefaults()
+ {
+ super.performDefaults();
+ }
+}
\ No newline at end of file