You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2009/08/11 13:46:26 UTC
svn commit: r803074 - 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/resources/
Author: seelmann
Date: Tue Aug 11 11:46:26 2009
New Revision: 803074
URL: http://svn.apache.org/viewvc?rev=803074&view=rev
Log:
DIRSTUDIO-516:
o created extension point for entry editors
o created interface which needs to be implemented by entry editors
o added method to plugin class to find existing implementations
o added an example entry editor extension, to be removed later
Added:
directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/
directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorExtension.java
directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/IEntryEditor.java
directory/studio/trunk/ldapbrowser-ui/src/main/resources/
directory/studio/trunk/ldapbrowser-ui/src/main/resources/entryEditors.exsd
Modified:
directory/studio/trunk/ldapbrowser-ui/plugin.xml
directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIConstants.java
directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIPlugin.java
Modified: directory/studio/trunk/ldapbrowser-ui/plugin.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/plugin.xml?rev=803074&r1=803073&r2=803074&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/plugin.xml (original)
+++ directory/studio/trunk/ldapbrowser-ui/plugin.xml Tue Aug 11 11:46:26 2009
@@ -17,8 +17,9 @@
specific language governing permissions and limitations
under the License.
-->
-<?eclipse version="3.0"?>
+<?eclipse version="3.2"?>
<plugin>
+ <extension-point id="org.apache.directory.studio.entryeditors" name="Entry Editors" schema="src/main/resources/entryEditors.exsd"/>
<extension
point="org.eclipse.ui.perspectives">
@@ -425,5 +426,18 @@
</description>
</decorator>
</extension>
+ <extension
+ point="org.apache.directory.studio.entryeditors">
+ <entryEditor
+ class="org.apache.directory.studio.ldapbrowser.ui.editors.entry.EntryEditor"
+ description="Example Entry Editor"
+ editorId="%Editor_EntryEditor_id"
+ icon="resources/icons/browser_entryeditor.gif"
+ id="org.apache.directory.studio.exampleentryeditor"
+ name="Example Entry Editor"
+ priority="5"
+ multiWindow="false">
+ </entryEditor>
+ </extension>
</plugin>
Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorExtension.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorExtension.java?rev=803074&view=auto
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorExtension.java (added)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorExtension.java Tue Aug 11 11:46:26 2009
@@ -0,0 +1,272 @@
+/*
+ * 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 org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+/**
+ * A bean class to hold the entry editor extension point properties.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class EntryEditorExtension
+{
+
+ /** The ID. */
+ private String id = null;
+
+ /** The name. */
+ private String name = null;
+
+ /** The description. */
+ private String description = null;
+
+ /** The icon. */
+ private ImageDescriptor icon = null;
+
+ /** The class name. */
+ private String className = null;
+
+ /** The editor id. */
+ private String editorId = null;
+
+ /** The multi window flag. */
+ private boolean multiWindow = true;
+
+ /** The priority. */
+ private int priority = 0;
+
+ /** The configuration element. */
+ private IConfigurationElement member = null;
+
+
+ /**
+ * Gets the id.
+ *
+ * @return the id
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+
+ /**
+ * Sets the id.
+ *
+ * @param id the new id
+ */
+ public void setId( String id )
+ {
+ this.id = id;
+ }
+
+
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+
+ /**
+ * Sets the name.
+ *
+ * @param name the new name
+ */
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+
+ /**
+ * Sets the description.
+ *
+ * @param description the new description
+ */
+ public void setDescription( String description )
+ {
+ this.description = description;
+ }
+
+
+ /**
+ * Gets the icon.
+ *
+ * @return the icon
+ */
+ public ImageDescriptor getIcon()
+ {
+ return icon;
+ }
+
+
+ /**
+ * Sets the icon.
+ *
+ * @param icon the new icon
+ */
+ public void setIcon( ImageDescriptor icon )
+ {
+ this.icon = icon;
+ }
+
+
+ /**
+ * Gets the class name.
+ *
+ * @return the class name
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+
+ /**
+ * Sets the class name.
+ *
+ * @param className the new class name
+ */
+ public void setClassName( String className )
+ {
+ this.className = className;
+ }
+
+
+ /**
+ * Gets the editor id.
+ *
+ * @return the editor id
+ */
+ public String getEditorId()
+ {
+ return editorId;
+ }
+
+
+ /**
+ * Sets the editor id.
+ *
+ * @param editorId the new editor id
+ */
+ public void setEditorId( String editorId )
+ {
+ this.editorId = editorId;
+ }
+
+
+ /**
+ * Checks if is multi window.
+ *
+ * @return true, if is multi window
+ */
+ public boolean isMultiWindow()
+ {
+ return multiWindow;
+ }
+
+
+ /**
+ * Sets the multi window.
+ *
+ * @param multiWindow the new multi window
+ */
+ public void setMultiWindow( boolean multiWindow )
+ {
+ this.multiWindow = multiWindow;
+ }
+
+
+ /**
+ * Gets the priority.
+ *
+ * @return the priority
+ */
+ public int getPriority()
+ {
+ return priority;
+ }
+
+
+ /**
+ * Sets the priority.
+ *
+ * @param priority the new priority
+ */
+ public void setPriority( int priority )
+ {
+ this.priority = priority;
+ }
+
+
+ /**
+ * Gets the member.
+ *
+ * @return the member
+ */
+ public IConfigurationElement getMember()
+ {
+ return member;
+ }
+
+
+ /**
+ * Sets the member.
+ *
+ * @param member the new member
+ */
+ public void setMember( IConfigurationElement member )
+ {
+ this.member = member;
+ }
+
+
+ @Override
+ public String toString()
+ {
+ return "EntryEditorExtension [className=" + className + ", description=" + description + ", editorId="
+ + editorId + ", icon=" + icon + ", id=" + id + ", member=" + member + ", name=" + name + ", priority="
+ + priority + ", multiWindow=" + multiWindow + "]";
+ }
+
+
+}
Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/IEntryEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/IEntryEditor.java?rev=803074&view=auto
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/IEntryEditor.java (added)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/IEntryEditor.java Tue Aug 11 11:46:26 2009
@@ -0,0 +1,44 @@
+/*
+ * 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 org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+
+
+/**
+ * An Entry Editor is used to display and edit and LDAP entry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface IEntryEditor
+{
+ /**
+ * This method indicates if the editor can handle the given entry.
+ *
+ * @param entry the entry.
+ *
+ * @return true if this editor can handle the entry, false otherwise.
+ */
+ public boolean canHandle( IEntry entry );
+
+}
Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIConstants.java?rev=803074&r1=803073&r2=803074&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIConstants.java (original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIConstants.java Tue Aug 11 11:46:26 2009
@@ -32,6 +32,8 @@
/** The plug-in ID */
public static final String PLUGIN_ID = BrowserUIPlugin.getDefault().getPluginProperties().getString( "Plugin_id" ); //$NON-NLS-1$
+ public static final String ENTRY_EDITOR_EXTENSION_POINT = "org.apache.directory.studio.entryeditors";
+
public static final String DN = "DN"; //$NON-NLS-1$
public static final String PREFERENCE_BROWSER_LINK_WITH_EDITOR = "browserLinkWithEditor"; //$NON-NLS-1$
@@ -205,4 +207,5 @@
"NewWizard_NewBookmarkWizard_id" ); //$NON-NLS-1$
public static final String WIZARD_NEW_SEARCH = BrowserUIPlugin.getDefault().getPluginProperties().getString(
"NewWizard_NewSearchWizard_id" ); //$NON-NLS-1$
+
}
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=803074&r1=803073&r2=803074&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 11:46:26 2009
@@ -23,10 +23,18 @@
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.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;
@@ -61,6 +69,14 @@
public void start( BundleContext context ) throws Exception
{
super.start( context );
+
+ // TODO: remove
+ Collection<EntryEditorExtension> entryEditorExtensions = getEntryEditorExtensions();
+ System.out.println( "Registered Entry Editors:" + entryEditorExtensions.size() );
+ for ( EntryEditorExtension entryEditorExtension : entryEditorExtensions )
+ {
+ System.out.println( entryEditorExtension.toString() );
+ }
}
@@ -176,4 +192,48 @@
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/resources/entryEditors.exsd
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/resources/entryEditors.exsd?rev=803074&view=auto
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/resources/entryEditors.exsd (added)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/resources/entryEditors.exsd Tue Aug 11 11:46:26 2009
@@ -0,0 +1,183 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.apache.directory.studio.ldapbrowser.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.apache.directory.studio.ldapbrowser.ui" id="org.apache.directory.studio.entryeditors" name="Entry Editors"/>
+ </appInfo>
+ <documentation>
+ An Entry Editor is used to display and edit an LDAP Entry.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="entryEditor" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="entryEditor">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The ID of the entry editor
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ The name of the entry editor
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="description" type="string">
+ <annotation>
+ <documentation>
+ The description of the entry editor.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="icon" type="string" use="required">
+ <annotation>
+ <documentation>
+ The icon of the entry editor
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="resource"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+ The class name of the entry editor implementation
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.apache.directory.studio.entryeditors.IEntryEditor"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="editorId" type="string" use="required">
+ <annotation>
+ <documentation>
+ The ID of the coresponding org.eclipse.ui.editors extension. Each Entry Editor must have a coresponding coresponding org.eclipse.ui.editors implementation.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.ui.editors"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="multiWindow" type="boolean" use="required">
+ <annotation>
+ <documentation>
+ True to indicate that one instance per entry is created.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="priority" type="string">
+ <annotation>
+ <documentation>
+ The priority of the entry editor, default to 0.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 1.5.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ 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.
+ </documentation>
+ </annotation>
+
+</schema>