directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1669604 [4/14] - in /directory/studio/trunk/plugins/templateeditor: ./ resources/ resources/icons/ resources/templates/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/directory/ src/main...
Date Fri, 27 Mar 2015 15:27:30 GMT
Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/DisplayEntryInTemplateMenuManager.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/DisplayEntryInTemplateMenuManager.java?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/DisplayEntryInTemplateMenuManager.java (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/DisplayEntryInTemplateMenuManager.java Fri Mar 27 15:27:27 2015
@@ -0,0 +1,207 @@
+/*
+ *  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.templateeditor.actions;
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+
+import org.apache.directory.studio.templateeditor.EntryTemplatePlugin;
+import org.apache.directory.studio.templateeditor.EntryTemplatePluginConstants;
+import org.apache.directory.studio.templateeditor.editor.TemplateEditorWidget;
+import org.apache.directory.studio.templateeditor.model.Template;
+
+
+/**
+ * This class implements the menu manager which is used in the Template Editor to
+ * allow to switch templates and open preferences.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DisplayEntryInTemplateMenuManager extends MenuManager implements IMenuListener
+{
+    /** The associated {@link TemplateEditorWidget} */
+    private TemplateEditorWidget templateEditorPage;
+
+
+    /**
+     * Creates a new instance of DisplayEntryInTemplateMenuManager.
+     *
+     * @param templateEditorPage
+     *      the associated editor page
+     */
+    public DisplayEntryInTemplateMenuManager( TemplateEditorWidget templateEditorPage )
+    {
+        super(
+            Messages.getString( "DisplayEntryInTemplateMenuManager.DiplayEntryIn" ), EntryTemplatePlugin.getDefault().getImageDescriptor( //$NON-NLS-1$
+                    EntryTemplatePluginConstants.IMG_SWITCH_TEMPLATE ), null );
+        addMenuListener( this );
+        this.templateEditorPage = templateEditorPage;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void menuAboutToShow( IMenuManager manager )
+    {
+        fillInMenuManager( manager, templateEditorPage );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isVisible()
+    {
+        return true;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isDynamic()
+    {
+        return true;
+    }
+
+
+    /**
+     * Fill the menu manager in with one menu item for each available template.
+     *
+     * @param menuManager
+     *      the menu manager
+     * @param templateEditorWidget
+     *      the associated editor widget
+     */
+    protected static void fillInMenuManager( IMenuManager menuManager, TemplateEditorWidget templateEditorWidget )
+    {
+        // Getting the matching templates and currently selected one from the editor page
+        List<Template> matchingTemplates = new ArrayList<Template>( templateEditorWidget.getMatchingTemplates() );
+        Template selectedTemplate = templateEditorWidget.getSelectedTemplate();
+
+        // Sorting the list of matching templates by their title
+        Collections.sort( matchingTemplates, new Comparator<Template>()
+        {
+            public int compare( Template o1, Template o2 )
+            {
+                if ( ( o1 == null ) && ( o2 == null ) )
+                {
+                    return 0;
+                }
+                else if ( ( o1 != null ) && ( o2 == null ) )
+                {
+                    return 1;
+                }
+                else if ( ( o1 == null ) && ( o2 != null ) )
+                {
+                    return -1;
+                }
+                else if ( ( o1 != null ) && ( o2 != null ) )
+                {
+                    String title1 = o1.getTitle();
+                    String title2 = o2.getTitle();
+                    if ( ( title1 == null ) && ( title2 == null ) )
+                    {
+                        return 0;
+                    }
+                    else if ( ( title1 != null ) && ( title2 == null ) )
+                    {
+                        return 1;
+                    }
+                    else if ( ( title1 == null ) && ( title2 != null ) )
+                    {
+                        return -1;
+                    }
+                    else if ( ( title1 != null ) && ( title2 != null ) )
+                    {
+                        return title1.compareTo( title2 );
+
+                    }
+                }
+
+                return 0;
+            };
+        } );
+
+        // As the Menu Manager is dynamic, we need to 
+        // remove all the previously added actions
+        menuManager.removeAll();
+
+        if ( ( matchingTemplates != null ) && ( matchingTemplates.size() > 0 ) )
+        {
+            // Looping on the matching templates and creating an action for each one
+            for ( Template matchingTemplate : matchingTemplates )
+            {
+                // Creating the action associated with the entry editor
+                menuManager.add( createAction( templateEditorWidget, matchingTemplate, ( matchingTemplate
+                    .equals( selectedTemplate ) ) ) );
+            }
+        }
+        else
+        {
+            // Creating a action that will be disabled when no template is available
+            Action noTemplateAction = new Action(
+                Messages.getString( "DisplayEntryInTemplateMenuManager.NoTemplate" ), Action.AS_CHECK_BOX ) //$NON-NLS-1$
+            {
+            };
+            noTemplateAction.setEnabled( false );
+            menuManager.add( noTemplateAction );
+        }
+
+        // Separator
+        menuManager.add( new Separator() );
+
+        // Preferences Action
+        menuManager.add( new EntryTemplatePreferencePageAction() );
+    }
+
+
+    /**
+     * Created the action.
+     *
+     * @param templateEditorWidget
+     *      the template editor widget
+     * @param template
+     *      the template
+     * @param isChecked
+     *      <code>true</code> if the action is checked,
+     *      <code>false</code> if not
+     * @return
+     *      the associated action
+     */
+    private static IAction createAction( TemplateEditorWidget templateEditorWidget, Template template, boolean isChecked )
+    {
+        Action action = new SwitchTemplateAction( templateEditorWidget, template );
+        action.setChecked( isChecked );
+
+        return action;
+    }
+}

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/EditorPagePropertiesAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/EditorPagePropertiesAction.java?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/EditorPagePropertiesAction.java (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/EditorPagePropertiesAction.java Fri Mar 27 15:27:27 2015
@@ -0,0 +1,76 @@
+/*
+ *  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.templateeditor.actions;
+
+
+import org.apache.directory.studio.entryeditors.EntryEditorInput;
+import org.apache.directory.studio.entryeditors.IEntryEditor;
+import org.apache.directory.studio.ldapbrowser.common.actions.PropertiesAction;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+
+
+/**
+ * This Action opens the Property Dialog for a given object.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class EditorPagePropertiesAction extends PropertiesAction
+{
+    /** The associated editor */
+    private IEntryEditor editor;
+
+
+    /**
+     * Creates a new instance of EntryEditorPropertiesAction.
+     *
+     * @param editor
+     *      the associated Entry Editor
+     */
+    public EditorPagePropertiesAction( IEntryEditor editor )
+    {
+        super();
+        this.editor = editor;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public IEntry[] getSelectedEntries()
+    {
+        // We're only returning the entry when no value is selected
+        if ( getSelectedValues().length == 0 )
+        {
+            if ( editor != null )
+            {
+                EntryEditorInput input = editor.getEntryEditorInput();
+
+                IEntry entry = ( ( EntryEditorInput ) input ).getResolvedEntry();
+                if ( entry != null )
+                {
+                    return new IEntry[]
+                        { entry };
+                }
+            }
+        }
+
+        return new IEntry[0];
+    }
+}
\ No newline at end of file

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/EntryTemplatePreferencePageAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/EntryTemplatePreferencePageAction.java?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/EntryTemplatePreferencePageAction.java (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/EntryTemplatePreferencePageAction.java Fri Mar 27 15:27:27 2015
@@ -0,0 +1,61 @@
+/*
+ *  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.templateeditor.actions;
+
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+import org.apache.directory.studio.templateeditor.EntryTemplatePluginConstants;
+
+
+/**
+ * The OpenEntryEditorsPreferencePageAction is used to open the 
+ * preference dialog with the entry editors preference page.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class EntryTemplatePreferencePageAction extends Action
+{
+
+    /**
+     * Creates a new instance of OpenBrowserPreferencePageAction.
+     */
+    public EntryTemplatePreferencePageAction()
+    {
+        super.setText( Messages.getString( "EntryTemplatePreferencePageAction.Preferences" ) ); //$NON-NLS-1$
+        setToolTipText( Messages.getString( "EntryTemplatePreferencePageAction.Preferences" ) ); //$NON-NLS-1$
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        Shell shell = Display.getCurrent().getActiveShell();
+        String pageId = EntryTemplatePluginConstants.PREF_TEMPLATE_ENTRY_EDITOR_PAGE_ID;
+        PreferencesUtil.createPreferenceDialogOn( shell, pageId, new String[]
+            { pageId }, null ).open();
+    }
+}

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/Messages.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/Messages.java?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/Messages.java (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/Messages.java Fri Mar 27 15:27:27 2015
@@ -0,0 +1,54 @@
+/*
+ *  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.templateeditor.actions;
+
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+/**
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class Messages
+{
+    private static final String BUNDLE_NAME = "org.apache.directory.studio.templateeditor.actions.messages"; //$NON-NLS-1$
+
+    private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
+
+
+    private Messages()
+    {
+    }
+
+
+    public static String getString( String key )
+    {
+        try
+        {
+            return RESOURCE_BUNDLE.getString( key );
+        }
+        catch ( MissingResourceException e )
+        {
+            return '!' + key + '!';
+        }
+    }
+}

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/RefreshAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/RefreshAction.java?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/RefreshAction.java (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/RefreshAction.java Fri Mar 27 15:27:27 2015
@@ -0,0 +1,109 @@
+/*
+ *  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.templateeditor.actions;
+
+
+import org.apache.directory.studio.connection.core.jobs.StudioConnectionJob;
+import org.apache.directory.studio.entryeditors.IEntryEditor;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeAttributesRunnable;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+/**
+ * This action refreshes the entry in the given editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class RefreshAction extends Action
+{
+    /** The associated editor */
+    private IEntryEditor editor;
+
+
+    /**
+     * Creates a new instance of RefreshAction.
+     *
+     * @param editor
+     *      the associated editor
+     */
+    public RefreshAction( IEntryEditor editor )
+    {
+        this.editor = editor;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_REFRESH );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        return org.apache.directory.studio.ldapbrowser.common.actions.Messages
+            .getString( "RefreshAction.RelaodAttributes" ); //$NON-NLS-1$
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        if ( editor != null )
+        {
+            return ( editor.getEntryEditorInput().getResolvedEntry() != null );
+        }
+
+        return false;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getActionDefinitionId()
+    {
+        return "org.eclipse.ui.file.refresh"; //$NON-NLS-1$
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        if ( editor != null )
+        {
+            IEntry entry = editor.getEntryEditorInput().getResolvedEntry();
+            new StudioConnectionJob( new InitializeAttributesRunnable( entry ) ).execute();
+        }
+    }
+}

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/SimpleActionProxy.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/SimpleActionProxy.java?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/SimpleActionProxy.java (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/SimpleActionProxy.java Fri Mar 27 15:27:27 2015
@@ -0,0 +1,94 @@
+/*
+ *  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.templateeditor.actions;
+
+
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.eclipse.jface.action.Action;
+
+
+/**
+ * This class wraps a {@link BrowserAction} as a standard JFace {@link Action}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SimpleActionProxy extends Action
+{
+    /** The {@link BrowserAction}*/
+    protected BrowserAction action;
+
+
+    /**
+     * Creates a new instance of SimpleActionProxy.
+     *
+     * @param action
+     *      the {@link BrowserAction}
+     * @param style
+     *      the style for the {@link Action}
+     */
+    public SimpleActionProxy( BrowserAction action, int style )
+    {
+        super( action.getText(), style );
+        this.action = action;
+
+        super.setImageDescriptor( action.getImageDescriptor() );
+        super.setActionDefinitionId( action.getCommandId() );
+    }
+
+
+    /**
+     * Creates a new instance of SimpleActionProxy.
+     *
+     * @param action
+     *      the {@link BrowserAction}
+     */
+    public SimpleActionProxy( BrowserAction action )
+    {
+        this( action, action.getStyle() );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        if ( action != null )
+        {
+            action.run();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        if ( action != null )
+        {
+            return action.isEnabled();
+        }
+        else
+        {
+            return false;
+        }
+    }
+}

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/SwitchTemplateAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/SwitchTemplateAction.java?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/SwitchTemplateAction.java (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/SwitchTemplateAction.java Fri Mar 27 15:27:27 2015
@@ -0,0 +1,81 @@
+/*
+ *  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.templateeditor.actions;
+
+
+import org.apache.directory.studio.entryeditors.IEntryEditor;
+import org.eclipse.jface.action.Action;
+
+import org.apache.directory.studio.templateeditor.editor.TemplateEditorWidget;
+import org.apache.directory.studio.templateeditor.model.Template;
+
+
+/**
+ * This Action switches the template editor widget to the given template.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SwitchTemplateAction extends Action
+{
+    /** The template editor widget */
+    private TemplateEditorWidget templateEditorWidget;
+
+    /** The template */
+    private Template template;
+
+
+    /**
+     * Creates a new instance of SwitchTemplateAction.
+     *
+     * @param templateEditorWidget
+     *      the template editor widget
+     * @param template
+     *      the template
+     */
+    public SwitchTemplateAction( TemplateEditorWidget templateEditorWidget, Template template )
+    {
+        super( template.getTitle(), Action.AS_CHECK_BOX );
+
+        this.templateEditorWidget = templateEditorWidget;
+        this.template = template;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        if ( ( templateEditorWidget != null ) && ( template != null ) )
+        {
+            // Switching the template
+            templateEditorWidget.switchTemplate( template );
+
+            // Getting the associated editor
+            IEntryEditor editor = templateEditorWidget.getEditor();
+            if ( editor instanceof SwitchTemplateListener )
+            {
+                // Calling the listener
+                ( ( SwitchTemplateListener ) editor ).templateSwitched( templateEditorWidget, template );
+            }
+        }
+    }
+}

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/SwitchTemplateListener.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/SwitchTemplateListener.java?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/SwitchTemplateListener.java (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/SwitchTemplateListener.java Fri Mar 27 15:27:27 2015
@@ -0,0 +1,43 @@
+/*
+ *  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.templateeditor.actions;
+
+
+import org.apache.directory.studio.templateeditor.editor.TemplateEditorWidget;
+import org.apache.directory.studio.templateeditor.model.Template;
+
+
+/**
+ * This interface defines a listener on 'Switch Template' events.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface SwitchTemplateListener
+{
+    /**
+     * This method is called when a template has been switched.
+     *
+     * @param templateEditorWidget
+     *      the template editor widget
+     * @param template
+     *      the template
+     */
+    public void templateSwitched( TemplateEditorWidget templateEditorWidget, Template template );
+}

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/messages.properties?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/messages.properties (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/messages.properties Fri Mar 27 15:27:27 2015
@@ -0,0 +1,20 @@
+# 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.
+DisplayEntryInTemplateAction.DisplayEntryIn=Display Entry In
+DisplayEntryInTemplateMenuManager.DiplayEntryIn=Display Entry In
+DisplayEntryInTemplateMenuManager.NoTemplate=No Template
+EntryTemplatePreferencePageAction.Preferences=Preferences...
\ No newline at end of file

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/messages_de.properties?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/messages_de.properties (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/messages_de.properties Fri Mar 27 15:27:27 2015
@@ -0,0 +1,22 @@
+# 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.
+DisplayEntryInTemplateAction.DisplayEntryIn=Eintrag anzeigen in
+
+DisplayEntryInTemplateMenuManager.DiplayEntryIn=Eintrag anzeigen in
+DisplayEntryInTemplateMenuManager.NoTemplate   =Kein Template
+
+EntryTemplatePreferencePageAction.Preferences=Benutzervorgaben...

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/messages_fr.properties?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/messages_fr.properties (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/actions/messages_fr.properties Fri Mar 27 15:27:27 2015
@@ -0,0 +1,20 @@
+# 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.
+DisplayEntryInTemplateAction.DisplayEntryIn=Afficher l''entr\u00E9e dans
+DisplayEntryInTemplateMenuManager.DiplayEntryIn=Afficher l''entr\u00E9e dans
+DisplayEntryInTemplateMenuManager.NoTemplate=Aucun mod\u00E8le
+EntryTemplatePreferencePageAction.Preferences=Pr\u00E9f\u00E9rences...
\ No newline at end of file

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/Messages.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/Messages.java?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/Messages.java (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/Messages.java Fri Mar 27 15:27:27 2015
@@ -0,0 +1,54 @@
+/*
+ *  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.templateeditor.editor;
+
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+/**
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class Messages
+{
+    private static final String BUNDLE_NAME = "org.apache.directory.studio.templateeditor.editor.messages"; //$NON-NLS-1$
+
+    private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
+
+
+    private Messages()
+    {
+    }
+
+
+    public static String getString( String key )
+    {
+        try
+        {
+            return RESOURCE_BUNDLE.getString( key );
+        }
+        catch ( MissingResourceException e )
+        {
+            return '!' + key + '!';
+        }
+    }
+}

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/MultiTabTemplateEntryEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/MultiTabTemplateEntryEditor.java?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/MultiTabTemplateEntryEditor.java (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/MultiTabTemplateEntryEditor.java Fri Mar 27 15:27:27 2015
@@ -0,0 +1,37 @@
+/*
+ *  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.templateeditor.editor;
+
+
+/**
+ * An entry editor the opens entries in a single editor for each entry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MultiTabTemplateEntryEditor extends TemplateEntryEditor
+{
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isAutoSave()
+    {
+        return false;
+    }
+}

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/SingleTabTemplateEntryEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/SingleTabTemplateEntryEditor.java?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/SingleTabTemplateEntryEditor.java (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/SingleTabTemplateEntryEditor.java Fri Mar 27 15:27:27 2015
@@ -0,0 +1,37 @@
+/*
+ *  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.templateeditor.editor;
+
+
+/**
+ * An entry editor the opens all entries in one single editor tab.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SingleTabTemplateEntryEditor extends TemplateEntryEditor
+{
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isAutoSave()
+    {
+        return false;
+    }
+}

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/TemplateEditorWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/TemplateEditorWidget.java?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/TemplateEditorWidget.java (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/TemplateEditorWidget.java Fri Mar 27 15:27:27 2015
@@ -0,0 +1,649 @@
+/*
+ *  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.templateeditor.editor;
+
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.directory.studio.entryeditors.EntryEditorInput;
+import org.apache.directory.studio.entryeditors.IEntryEditor;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.widgets.Form;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+import org.apache.directory.studio.templateeditor.EntryTemplatePlugin;
+import org.apache.directory.studio.templateeditor.EntryTemplatePluginUtils;
+import org.apache.directory.studio.templateeditor.actions.DisplayEntryInTemplateAction;
+import org.apache.directory.studio.templateeditor.actions.DisplayEntryInTemplateMenuManager;
+import org.apache.directory.studio.templateeditor.actions.EditorPagePropertiesAction;
+import org.apache.directory.studio.templateeditor.actions.RefreshAction;
+import org.apache.directory.studio.templateeditor.actions.SimpleActionProxy;
+import org.apache.directory.studio.templateeditor.editor.widgets.EditorCheckbox;
+import org.apache.directory.studio.templateeditor.editor.widgets.EditorComposite;
+import org.apache.directory.studio.templateeditor.editor.widgets.EditorDate;
+import org.apache.directory.studio.templateeditor.editor.widgets.EditorFileChooser;
+import org.apache.directory.studio.templateeditor.editor.widgets.EditorImage;
+import org.apache.directory.studio.templateeditor.editor.widgets.EditorLabel;
+import org.apache.directory.studio.templateeditor.editor.widgets.EditorLink;
+import org.apache.directory.studio.templateeditor.editor.widgets.EditorListbox;
+import org.apache.directory.studio.templateeditor.editor.widgets.EditorPassword;
+import org.apache.directory.studio.templateeditor.editor.widgets.EditorRadioButtons;
+import org.apache.directory.studio.templateeditor.editor.widgets.EditorSection;
+import org.apache.directory.studio.templateeditor.editor.widgets.EditorSpinner;
+import org.apache.directory.studio.templateeditor.editor.widgets.EditorTable;
+import org.apache.directory.studio.templateeditor.editor.widgets.EditorTextField;
+import org.apache.directory.studio.templateeditor.editor.widgets.EditorWidget;
+import org.apache.directory.studio.templateeditor.model.Template;
+import org.apache.directory.studio.templateeditor.model.widgets.TemplateCheckbox;
+import org.apache.directory.studio.templateeditor.model.widgets.TemplateComposite;
+import org.apache.directory.studio.templateeditor.model.widgets.TemplateDate;
+import org.apache.directory.studio.templateeditor.model.widgets.TemplateFileChooser;
+import org.apache.directory.studio.templateeditor.model.widgets.TemplateForm;
+import org.apache.directory.studio.templateeditor.model.widgets.TemplateImage;
+import org.apache.directory.studio.templateeditor.model.widgets.TemplateLabel;
+import org.apache.directory.studio.templateeditor.model.widgets.TemplateLink;
+import org.apache.directory.studio.templateeditor.model.widgets.TemplateListbox;
+import org.apache.directory.studio.templateeditor.model.widgets.TemplatePassword;
+import org.apache.directory.studio.templateeditor.model.widgets.TemplateRadioButtons;
+import org.apache.directory.studio.templateeditor.model.widgets.TemplateSection;
+import org.apache.directory.studio.templateeditor.model.widgets.TemplateSpinner;
+import org.apache.directory.studio.templateeditor.model.widgets.TemplateTable;
+import org.apache.directory.studio.templateeditor.model.widgets.TemplateTextField;
+import org.apache.directory.studio.templateeditor.model.widgets.TemplateWidget;
+
+
+/**
+ * This class implements a widget for the Template Editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class TemplateEditorWidget
+{
+    /** The associated editor */
+    private IEntryEditor editor;
+
+    /** The flag to know whether or not the widget has been initialized */
+    private boolean initialized = false;
+
+    /** The parent {@link Composite} of the widget */
+    private Composite parent;
+
+    /** The associated {@link FormToolkit} */
+    private FormToolkit toolkit;
+
+    /** The associated {@link ScrolledForm} */
+    private ScrolledForm form;
+
+    /** The currently selected template */
+    private Template selectedTemplate;
+
+    /** The context menu */
+    private Menu contextMenu;
+
+    /** The list of editor widgets */
+    private Map<TemplateWidget, EditorWidget<? extends TemplateWidget>> editorWidgets = new HashMap<TemplateWidget, EditorWidget<? extends TemplateWidget>>();
+
+
+    /**
+     * Creates a new instance of TemplateEditorWidget.
+     *
+     * @param editor
+     *      the editor
+     */
+    public TemplateEditorWidget( IEntryEditor editor )
+    {
+        this.editor = editor;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void init( Composite parent )
+    {
+        initialized = true;
+        this.parent = parent;
+
+        // Creating the toolkit
+        toolkit = new FormToolkit( parent.getDisplay() );
+
+        // Creating the new form
+        form = toolkit.createScrolledForm( parent );
+        form.getBody().setLayout( new GridLayout() );
+
+        form.getToolBarManager().add( new RefreshAction( getEditor() ) );
+        form.getToolBarManager().add( new Separator() );
+        form.getToolBarManager().add( new DisplayEntryInTemplateAction( this ) );
+        form.getToolBarManager().update( true );
+
+        // Creating the new menu manager
+        MenuManager menuManager = new MenuManager();
+        contextMenu = menuManager.createContextMenu( form );
+        form.setMenu( contextMenu );
+
+        // Adding actions to the menu manager
+        menuManager.add( new DisplayEntryInTemplateMenuManager( this ) );
+        menuManager.add( new Separator() );
+        menuManager.add( new RefreshAction( getEditor() ) );
+        menuManager.add( new Separator() );
+        menuManager.add( new SimpleActionProxy( new EditorPagePropertiesAction( getEditor() ) ) );
+
+        createFormContent();
+
+        parent.layout();
+    }
+
+
+    /**
+     * Creates the from content
+     */
+    private void createFormContent()
+    {
+        EntryEditorInput entryEditorInput = getEditor().getEntryEditorInput();
+
+        // Checking if the input is null
+        if ( entryEditorInput == null )
+        {
+            createFormContentUnableToDisplayTheEntry();
+        }
+        else
+        {
+            // Getting the entry and the template
+            IEntry entry = entryEditorInput.getSharedWorkingCopy( getEditor() );
+
+            // Special case in the case the entry is null
+            if ( entry == null )
+            {
+                // Hiding the context menu
+                form.setMenu( null );
+
+                // Creating the form content
+                createFormContentNoEntrySelected();
+            }
+            else
+            {
+                // Showing the context menu
+                form.setMenu( contextMenu );
+
+                // Checking if a template is selected
+                if ( selectedTemplate == null )
+                {
+                    List<Template> matchingTemplates = EntryTemplatePluginUtils.getMatchingTemplates( entry );
+                    if ( ( matchingTemplates != null ) && ( matchingTemplates.size() > 0 ) )
+                    {
+                        // Looking for the default template
+                        for ( Template matchingTemplate : matchingTemplates )
+                        {
+                            if ( EntryTemplatePlugin.getDefault().getTemplatesManager().isDefaultTemplate(
+                                matchingTemplate ) )
+                            {
+                                selectedTemplate = matchingTemplate;
+                                break;
+                            }
+                        }
+
+                        // If no default template has been found,
+                        // select the first one
+                        if ( selectedTemplate == null )
+                        {
+                            // Assigning the first template as the selected one
+                            selectedTemplate = matchingTemplates.get( 0 );
+                        }
+
+                        // Creating the form content
+                        createFormContentFromTemplate();
+                    }
+                    else
+                    {
+                        // Creating the form content
+                        createFormContentNoTemplateMatching();
+                    }
+                }
+                else
+                {
+                    // Creating the form content
+                    createFormContentFromTemplate();
+                }
+            }
+        }
+
+        form.layout( true, true );
+    }
+
+
+    /**
+     * Gets the associated editor.
+     *
+     * @return
+     */
+    public IEntryEditor getEditor()
+    {
+        return editor;
+    }
+
+
+    /**
+     * Creates the form UI in case where the entry cannot be displayed.
+     */
+    private void createFormContentUnableToDisplayTheEntry()
+    {
+        // Displaying an error message
+        form.setText( Messages.getString( "TemplateEditorWidget.UnableToDisplayTheEntry" ) ); //$NON-NLS-1$
+        form.setImage( PlatformUI.getWorkbench().getSharedImages().getImage( ISharedImages.IMG_OBJS_ERROR_TSK ) );
+    }
+
+
+    /**
+     * Creates the form UI from the template.
+     * 
+     * @param managedForm
+     *            the form
+     */
+    private void createFormContentFromTemplate()
+    {
+        form.setText( selectedTemplate.getTitle() );
+
+        // Getting the template form
+        TemplateForm templateForm = selectedTemplate.getForm();
+
+        // Creating the children widgets
+        if ( templateForm.hasChildren() )
+        {
+            for ( TemplateWidget templateWidget : templateForm.getChildren() )
+            {
+                createFormTemplateWidget( form.getBody(), templateWidget );
+            }
+        }
+    }
+
+
+    /**
+     * Creates the editor widget associated with the {@link TemplateWidget} object .
+     * 
+     * @param parent
+     *      the parent composite
+     * @param templateWidget
+     *      the template widget
+     */
+    private void createFormTemplateWidget( Composite parent, TemplateWidget templateWidget )
+    {
+        // The widget composite
+        Composite widgetComposite = null;
+
+        // Creating the widget according to its type
+        if ( templateWidget instanceof TemplateCheckbox )
+        {
+            // Creating the editor checkbox
+            EditorCheckbox editorCheckbox = new EditorCheckbox( getEditor(), ( TemplateCheckbox ) templateWidget,
+                getToolkit() );
+            editorWidgets.put( templateWidget, editorCheckbox );
+
+            // Creating the UI
+            widgetComposite = editorCheckbox.createWidget( parent );
+        }
+        else if ( templateWidget instanceof TemplateComposite )
+        {
+            // Creating the editor composite
+            EditorComposite editorComposite = new EditorComposite( getEditor(), ( TemplateComposite ) templateWidget,
+                getToolkit() );
+            editorWidgets.put( templateWidget, editorComposite );
+
+            // Creating the UI
+            widgetComposite = editorComposite.createWidget( parent );
+        }
+        else if ( templateWidget instanceof TemplateDate )
+        {
+            // Creating the editor date
+            EditorDate editorDate = new EditorDate( getEditor(), ( TemplateDate ) templateWidget, getToolkit() );
+            editorWidgets.put( templateWidget, editorDate );
+
+            // Creating the UI
+            widgetComposite = editorDate.createWidget( parent );
+        }
+        else if ( templateWidget instanceof TemplateFileChooser )
+        {
+            // Creating the editor file chooser
+            EditorFileChooser editorFileChooser = new EditorFileChooser( getEditor(),
+                ( TemplateFileChooser ) templateWidget, getToolkit() );
+            editorWidgets.put( templateWidget, editorFileChooser );
+
+            // Creating the UI
+            widgetComposite = editorFileChooser.createWidget( parent );
+        }
+        else if ( templateWidget instanceof TemplateImage )
+        {
+            // Creating the editor image
+            EditorImage editorImage = new EditorImage( getEditor(), ( TemplateImage ) templateWidget, getToolkit() );
+            editorWidgets.put( templateWidget, editorImage );
+
+            // Creating the UI
+            widgetComposite = editorImage.createWidget( parent );
+        }
+        else if ( templateWidget instanceof TemplateLabel )
+        {
+            // Creating the editor label
+            EditorLabel editorLabel = new EditorLabel( getEditor(), ( TemplateLabel ) templateWidget, getToolkit() );
+            editorWidgets.put( templateWidget, editorLabel );
+
+            // Creating the UI
+            widgetComposite = editorLabel.createWidget( parent );
+        }
+        else if ( templateWidget instanceof TemplateLink )
+        {
+            // Creating the editor link
+            EditorLink editorLink = new EditorLink( getEditor(), ( TemplateLink ) templateWidget, getToolkit() );
+            editorWidgets.put( templateWidget, editorLink );
+
+            // Creating the UI
+            widgetComposite = editorLink.createWidget( parent );
+        }
+        else if ( templateWidget instanceof TemplateListbox )
+        {
+            // Creating the editor link
+            EditorListbox editorListbox = new EditorListbox( getEditor(), ( TemplateListbox ) templateWidget,
+                getToolkit() );
+            editorWidgets.put( templateWidget, editorListbox );
+
+            // Creating the UI
+            widgetComposite = editorListbox.createWidget( parent );
+        }
+        else if ( templateWidget instanceof TemplatePassword )
+        {
+            // Creating the editor password
+            EditorPassword editorPassword = new EditorPassword( getEditor(), ( TemplatePassword ) templateWidget,
+                getToolkit() );
+            editorWidgets.put( templateWidget, editorPassword );
+
+            // Creating the UI
+            widgetComposite = editorPassword.createWidget( parent );
+        }
+        else if ( templateWidget instanceof TemplateRadioButtons )
+        {
+            // Creating the editor radio buttons
+            EditorRadioButtons editorRadioButtons = new EditorRadioButtons( getEditor(),
+                ( TemplateRadioButtons ) templateWidget, getToolkit() );
+            editorWidgets.put( templateWidget, editorRadioButtons );
+
+            // Creating the UI
+            widgetComposite = editorRadioButtons.createWidget( parent );
+        }
+        else if ( templateWidget instanceof TemplateSection )
+        {
+            // Creating the editor section
+            EditorSection editorSection = new EditorSection( getEditor(), ( TemplateSection ) templateWidget,
+                getToolkit() );
+            editorWidgets.put( templateWidget, editorSection );
+
+            // Creating the UI
+            widgetComposite = editorSection.createWidget( parent );
+        }
+        else if ( templateWidget instanceof TemplateSpinner )
+        {
+            // Creating the editor spinner
+            EditorSpinner editorSpinner = new EditorSpinner( getEditor(), ( TemplateSpinner ) templateWidget,
+                getToolkit() );
+            editorWidgets.put( templateWidget, editorSpinner );
+
+            // Creating the UI
+            widgetComposite = editorSpinner.createWidget( parent );
+        }
+        else if ( templateWidget instanceof TemplateTable )
+        {
+            // Creating the editor table
+            EditorTable editorTable = new EditorTable( getEditor(), ( TemplateTable ) templateWidget, getToolkit() );
+            editorWidgets.put( templateWidget, editorTable );
+
+            // Creating the UI
+            widgetComposite = editorTable.createWidget( parent );
+        }
+        else if ( templateWidget instanceof TemplateTextField )
+        {
+            // Creating the editor text field
+            EditorTextField editorTextField = new EditorTextField( getEditor(), ( TemplateTextField ) templateWidget,
+                getToolkit() );
+            editorWidgets.put( templateWidget, editorTextField );
+
+            // Creating the UI
+            widgetComposite = editorTextField.createWidget( parent );
+        }
+
+        // Recursively looping on children
+        if ( templateWidget.hasChildren() )
+        {
+            for ( TemplateWidget templateWidgetChild : templateWidget.getChildren() )
+            {
+                createFormTemplateWidget( widgetComposite, templateWidgetChild );
+            }
+        }
+    }
+
+
+    /**
+     * Creates the form UI in case where no entry is selected.
+     */
+    private void createFormContentNoEntrySelected()
+    {
+        // Displaying an error message
+        form.setText( Messages.getString( "TemplateEditorWidget.NoEntrySelected" ) ); //$NON-NLS-1$
+    }
+
+
+    /**
+     * Creates the form UI in case where no template is matching.
+     */
+    private void createFormContentNoTemplateMatching()
+    {
+        // Displaying an error message
+        form.setText( Messages.getString( "TemplateEditorWidget.NoTemplateIsMatchingThisEntry" ) ); //$NON-NLS-1$
+    }
+
+
+    /**
+     * Gets the {@link FormToolkit} associated with the editor page.
+     *
+     * @return
+     *      the {@link FormToolkit} associated with the editor page
+     */
+    public FormToolkit getToolkit()
+    {
+        return toolkit;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        //
+        // Disposing the toolkit, form and widgets
+        //
+
+        // Toolkit
+        if ( toolkit != null )
+        {
+            toolkit.dispose();
+        }
+
+        // Form
+        if ( ( form != null ) && ( !form.isDisposed() ) )
+        {
+            form.dispose();
+        }
+
+        // Widgets
+        for ( TemplateWidget key : editorWidgets.keySet() )
+        {
+            EditorWidget<?> widget = editorWidgets.get( key );
+            widget.dispose();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void update()
+    {
+        if ( isInitialized() )
+        {
+            // Updating widgets
+            for ( TemplateWidget key : editorWidgets.keySet() )
+            {
+                EditorWidget<?> widget = editorWidgets.get( key );
+                widget.update();
+            }
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setFocus()
+    {
+        if ( ( form != null ) && ( !form.isDisposed() ) )
+        {
+            form.setFocus();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void editorInputChanged()
+    {
+        if ( isInitialized() )
+        {
+            // Resetting the template
+            selectedTemplate = null;
+
+            // Updating the UI
+            disposeAndRecreateUI();
+        }
+    }
+
+
+    /**
+     * Gets the {@link List} of templates matching the current entry.   
+     *
+     * @return
+     *      the {@link List} of templates matching the current entry
+     */
+    public List<Template> getMatchingTemplates()
+    {
+        return EntryTemplatePluginUtils.getMatchingTemplates( getEditor().getEntryEditorInput().getSharedWorkingCopy(
+            getEditor() ) );
+    }
+
+
+    /**
+     * Gets the selected template.
+     *
+     * @return
+     *      the selected template
+     */
+    public Template getSelectedTemplate()
+    {
+        return selectedTemplate;
+    }
+
+
+    /**
+     * Displays the entry with the given template.
+     *
+     * @param selectedTemplate
+     *      the selected template
+     */
+    public void switchTemplate( Template selectedTemplate )
+    {
+        // Assigning the selected template
+        this.selectedTemplate = selectedTemplate;
+
+        // Updating the UI
+        disposeAndRecreateUI();
+    }
+
+
+    /**
+     * Disposes and re-creates the UI (if the editor page has been initialized).
+     */
+    private void disposeAndRecreateUI()
+    {
+        if ( isInitialized() )
+        {
+            // Disposing the previously created form
+            if ( ( form != null ) && ( !form.isDisposed() ) )
+            {
+                // Disposing the from (and all it's children elements
+                form.dispose();
+
+                // Disposing template widgets
+                for ( TemplateWidget key : editorWidgets.keySet() )
+                {
+                    EditorWidget<?> widget = editorWidgets.get( key );
+                    widget.dispose();
+                }
+            }
+
+            // Clearing all previously created editor widgets (which are now disposed)
+            editorWidgets.clear();
+
+            // Recreating the UI
+            init( parent );
+        }
+    }
+
+
+    /**
+     * Gets the associated {@link Form}.
+     *
+     * @return
+     *      the associated {@link Form}
+     */
+    public ScrolledForm getForm()
+    {
+        return form;
+    }
+
+
+    /**
+     * Indicated if the widget has been initialized.
+     *
+     * @return
+     *      <code>true</code> if the widget has been initialized,
+     *      <code>false</code> if not
+     */
+    public boolean isInitialized()
+    {
+        return initialized;
+    }
+}
\ No newline at end of file

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/TemplateEntryEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/TemplateEntryEditor.java?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/TemplateEntryEditor.java (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/TemplateEntryEditor.java Fri Mar 27 15:27:27 2015
@@ -0,0 +1,316 @@
+/*
+ *  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.templateeditor.editor;
+
+
+import org.apache.directory.studio.entryeditors.EntryEditorInput;
+import org.apache.directory.studio.entryeditors.EntryEditorUtils;
+import org.apache.directory.studio.entryeditors.IEntryEditor;
+import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.INavigationLocation;
+import org.eclipse.ui.INavigationLocationProvider;
+import org.eclipse.ui.IReusableEditor;
+import org.eclipse.ui.IShowEditorInput;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.EditorPart;
+
+import org.apache.directory.studio.templateeditor.EntryTemplatePlugin;
+import org.apache.directory.studio.templateeditor.EntryTemplatePluginConstants;
+import org.apache.directory.studio.templateeditor.EntryTemplatePluginUtils;
+
+
+/**
+ * This class implements the Template Entry Editor.
+ * <p>
+ * This editor is composed of a three tabs TabFolder object:
+ * <ul>
+ *  <li>the Template Editor itself</li>
+ *  <li>the Table Editor</li>
+ *  <li>the LDIF Editor</li>
+ * </ul>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class TemplateEntryEditor extends EditorPart implements INavigationLocationProvider, IEntryEditor,
+    IReusableEditor, IShowEditorInput
+{
+    /** The Template Editor page */
+    private TemplateEditorWidget templateEditorWidget;
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void init( IEditorSite site, IEditorInput input ) throws PartInitException
+    {
+        setSite( site );
+        setInput( input );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void createPartControl( Composite parent )
+    {
+        templateEditorWidget = new TemplateEditorWidget( this );
+        templateEditorWidget.init( parent );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void workingCopyModified( Object source )
+    {
+        update();
+
+        if ( !isAutoSave() )
+        {
+            // mark as dirty
+            firePropertyChange( PROP_DIRTY );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        // Template Editor Widget
+        if ( templateEditorWidget != null )
+        {
+            templateEditorWidget.dispose();
+        }
+
+        super.dispose();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean canHandle( IEntry entry )
+    {
+        int useTemplateEditorFor = EntryTemplatePlugin.getDefault().getPreferenceStore().getInt(
+            EntryTemplatePluginConstants.PREF_USE_TEMPLATE_EDITOR_FOR );
+        if ( useTemplateEditorFor == EntryTemplatePluginConstants.PREF_USE_TEMPLATE_EDITOR_FOR_ANY_ENTRY )
+        {
+            return true;
+        }
+        else if ( useTemplateEditorFor == EntryTemplatePluginConstants.PREF_USE_TEMPLATE_EDITOR_FOR_ENTRIES_WITH_TEMPLATE )
+        {
+            if ( entry == null )
+            {
+                return true;
+            }
+
+            return canBeHandledWithATemplate( entry );
+        }
+
+        return false;
+    }
+
+
+    /**
+     * Indicates whether or not the entry can be handled with a (at least) template.
+     *
+     * @param entry
+     *      the entry
+     * @return
+     *      <code>true</code> if the entry can be handled with a template,
+     *      <code>false</code> if not.
+     */
+    private boolean canBeHandledWithATemplate( IEntry entry )
+    {
+        return ( EntryTemplatePluginUtils.getMatchingTemplates( entry ).size() > 0 );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void doSave( IProgressMonitor monitor )
+    {
+        if ( !isAutoSave() )
+        {
+            EntryEditorInput eei = getEntryEditorInput();
+            eei.saveSharedWorkingCopy( true, this );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isDirty()
+    {
+        return getEntryEditorInput().isSharedWorkingCopyDirty( this );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isSaveAsAllowed()
+    {
+        return false;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void doSaveAs()
+    {
+        // Nothing to do, will never occur as "Save As..." is not allowed
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setFocus()
+    {
+        if ( templateEditorWidget != null )
+        {
+            templateEditorWidget.setFocus();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public EntryEditorInput getEntryEditorInput()
+    {
+        Object editorInput = getEditorInput();
+        if ( ( editorInput != null ) && ( editorInput instanceof EntryEditorInput ) )
+        {
+            return ( EntryEditorInput ) editorInput;
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Updates the selected AbstractTemplateEntryEditorPage.
+     */
+    private void update()
+    {
+        if ( templateEditorWidget != null )
+        {
+            templateEditorWidget.update();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setInput( IEditorInput input )
+    {
+        super.setInput( input );
+
+        setPartName( input.getName() );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public INavigationLocation createEmptyNavigationLocation()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public INavigationLocation createNavigationLocation()
+    {
+        return new TemplateEntryEditorNavigationLocation( this );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void showEditorInput( IEditorInput input )
+    {
+        if ( input instanceof EntryEditorInput )
+        {
+            // If the editor is dirty, let's ask for a save before changing the input
+            if ( isDirty() )
+            {
+                if ( !EntryEditorUtils.askSaveSharedWorkingCopyBeforeInputChange( this ) )
+                {
+                    return;
+                }
+            }
+
+            /*
+             * Workaround to make link-with-editor working for the single-tab editor:
+             * The call of firePropertyChange is used to inform the link-with-editor action.
+             * However firePropertyChange also modifies the navigation history.
+             * Thus, a dummy input with the real entry but a null extension is set.
+             * This avoids to modification of the navigation history.
+             * Afterwards the real input is set.
+             */
+            EntryEditorInput eei = ( EntryEditorInput ) input;
+            IEntry entryInput = eei.getEntryInput();
+            ISearchResult searchResultInput = eei.getSearchResultInput();
+            IBookmark bookmarkInput = eei.getBookmarkInput();
+            EntryEditorInput dummyInput;
+            if ( entryInput != null )
+            {
+                dummyInput = new EntryEditorInput( entryInput, null );
+            }
+            else if ( searchResultInput != null )
+            {
+                dummyInput = new EntryEditorInput( searchResultInput, null );
+            }
+            else
+            {
+                dummyInput = new EntryEditorInput( bookmarkInput, null );
+            }
+            setInput( dummyInput );
+            firePropertyChange( IEditorPart.PROP_INPUT );
+
+            // now set the real input and mark history location
+            setInput( input );
+            getSite().getPage().getNavigationHistory().markLocation( this );
+
+            // Updating the input on the template editor widget
+            templateEditorWidget.editorInputChanged();
+        }
+    }
+
+}

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/TemplateEntryEditorNavigationLocation.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/TemplateEntryEditorNavigationLocation.java?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/TemplateEntryEditorNavigationLocation.java (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/TemplateEntryEditorNavigationLocation.java Fri Mar 27 15:27:27 2015
@@ -0,0 +1,242 @@
+/*
+ *  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.templateeditor.editor;
+
+
+import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.studio.entryeditors.EntryEditorExtension;
+import org.apache.directory.studio.entryeditors.EntryEditorInput;
+import org.apache.directory.studio.entryeditors.EntryEditorManager;
+import org.apache.directory.studio.entryeditors.EntryEditorUtils;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
+import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.INavigationLocation;
+import org.eclipse.ui.NavigationLocation;
+
+
+/**
+ * This class is used to mark the entry editor input to the navigation history.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class TemplateEntryEditorNavigationLocation extends NavigationLocation
+{
+    private static final String BOOKMARK_TAG = "BOOKMARK"; //$NON-NLS-1$
+    private static final String CONNECTION_TAG = "CONNECTION"; //$NON-NLS-1$
+    private static final String DN_TAG = "DN"; //$NON-NLS-1$
+    private static final String EXTENSION_TAG = "EXTENSION"; //$NON-NLS-1$
+    private static final String SEARCH_TAG = "SEARCH"; //$NON-NLS-1$
+    private static final String TYPE_BOOKMARK_VALUE = "IBookmark"; //$NON-NLS-1$
+    private static final String TYPE_SEARCHRESULT_VALUE = "ISearchResult"; //$NON-NLS-1$
+    private static final String TYPE_TAG = "TYPE"; //$NON-NLS-1$
+    private static final String TYPE_ENTRY_VALUE = "IEntry"; //$NON-NLS-1$
+
+
+    /**
+     * Creates a new instance of EntryEditorNavigationLocation.
+     *
+     * @param editor the entry editor
+     */
+    protected TemplateEntryEditorNavigationLocation( IEditorPart editor )
+    {
+        super( editor );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        String text = EntryEditorUtils.getHistoryNavigationText( getEntryEditorInput() );
+        return text != null ? text : super.getText();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void saveState( IMemento memento )
+    {
+        EntryEditorInput eei = getEntryEditorInput();
+        if ( eei != null )
+        {
+            memento.putString( EXTENSION_TAG, eei.getExtension().getId() );
+            if ( eei.getEntryInput() != null )
+            {
+                IEntry entry = eei.getEntryInput();
+                memento.putString( TYPE_TAG, TYPE_ENTRY_VALUE );
+                memento.putString( DN_TAG, entry.getDn().getName() );
+                memento.putString( CONNECTION_TAG, entry.getBrowserConnection().getConnection().getId() );
+            }
+            else if ( eei.getSearchResultInput() != null )
+            {
+                ISearchResult searchResult = eei.getSearchResultInput();
+                memento.putString( TYPE_TAG, TYPE_SEARCHRESULT_VALUE );
+                memento.putString( DN_TAG, searchResult.getDn().getName() );
+                memento.putString( SEARCH_TAG, searchResult.getSearch().getName() );
+                memento.putString( CONNECTION_TAG, searchResult.getSearch().getBrowserConnection().getConnection()
+                    .getId() );
+            }
+            else if ( eei.getBookmarkInput() != null )
+            {
+                IBookmark bookmark = eei.getBookmarkInput();
+                memento.putString( TYPE_TAG, TYPE_BOOKMARK_VALUE );
+                memento.putString( BOOKMARK_TAG, bookmark.getName() );
+                memento.putString( CONNECTION_TAG, bookmark.getBrowserConnection().getConnection().getId() );
+            }
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void restoreState( IMemento memento )
+    {
+        try
+        {
+            String type = memento.getString( TYPE_TAG );
+            String extensionId = memento.getString( EXTENSION_TAG );
+            EntryEditorManager entryEditorManager = BrowserUIPlugin.getDefault().getEntryEditorManager();
+            EntryEditorExtension entryEditorExtension = entryEditorManager.getEntryEditorExtension( extensionId );
+            if ( TYPE_ENTRY_VALUE.equals( type ) )
+            {
+                IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager()
+                    .getBrowserConnectionById( memento.getString( CONNECTION_TAG ) );
+                Dn dn = new Dn( memento.getString( DN_TAG ) );
+                IEntry entry = connection.getEntryFromCache( dn );
+                super.setInput( new EntryEditorInput( entry, entryEditorExtension ) );
+            }
+            else if ( TYPE_SEARCHRESULT_VALUE.equals( type ) )
+            {
+                IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager()
+                    .getBrowserConnectionById( memento.getString( CONNECTION_TAG ) );
+                ISearch search = connection.getSearchManager().getSearch( memento.getString( SEARCH_TAG ) );
+                ISearchResult[] searchResults = search.getSearchResults();
+                Dn dn = new Dn( memento.getString( DN_TAG ) );
+                for ( int i = 0; i < searchResults.length; i++ )
+                {
+                    if ( dn.equals( searchResults[i].getDn() ) )
+                    {
+                        super.setInput( new EntryEditorInput( searchResults[i], entryEditorExtension ) );
+                        break;
+                    }
+                }
+            }
+            else if ( TYPE_BOOKMARK_VALUE.equals( type ) )
+            {
+                IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager()
+                    .getBrowserConnectionById( memento.getString( CONNECTION_TAG ) );
+                IBookmark bookmark = connection.getBookmarkManager().getBookmark( memento.getString( BOOKMARK_TAG ) );
+                super.setInput( new EntryEditorInput( bookmark, entryEditorExtension ) );
+            }
+        }
+        catch ( LdapInvalidDnException e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void restoreLocation()
+    {
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean mergeInto( INavigationLocation currentLocation )
+    {
+        if ( currentLocation == null )
+        {
+            return false;
+        }
+
+        if ( getClass() != currentLocation.getClass() )
+        {
+            return false;
+        }
+
+        TemplateEntryEditorNavigationLocation location = ( TemplateEntryEditorNavigationLocation ) currentLocation;
+        Object other = location.getEntryEditorInput().getInput();
+        Object entry = getEntryEditorInput().getInput();
+
+        if ( other == null && entry == null )
+        {
+            return true;
+        }
+        else if ( other == null || entry == null )
+        {
+            return false;
+        }
+        else
+        {
+            return entry.equals( other );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void update()
+    {
+    }
+
+
+    /**
+     * Gets the input.
+     *
+     * @return the input
+     */
+    private EntryEditorInput getEntryEditorInput()
+    {
+        Object editorInput = getInput();
+        if ( editorInput != null && editorInput instanceof EntryEditorInput )
+        {
+            EntryEditorInput entryEditorInput = ( EntryEditorInput ) editorInput;
+            return entryEditorInput;
+        }
+
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString()
+    {
+        return "" + getEntryEditorInput().getInput(); //$NON-NLS-1$
+    }
+}
\ No newline at end of file

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/messages.properties?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/messages.properties (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/messages.properties Fri Mar 27 15:27:27 2015
@@ -0,0 +1,28 @@
+# 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.
+LdifEditorPage.LDIFEditor=LDIF Editor
+
+TableEditorPage.TableEditor=Table Editor
+
+TableEditorPageActionGroup.Advanced=Advanced
+TableEditorPageActionGroup.OpenSchemaBrowser=Open Schema Browser
+TableEditorPageActionGroup.ShowIn=Show In
+
+TemplateEditorWidget.NoEntrySelected=No Entry Selected
+TemplateEditorWidget.NoTemplateIsMatchingThisEntry=No template is matching this entry
+TemplateEditorWidget.TemplateEditor=Template Editor
+TemplateEditorWidget.UnableToDisplayTheEntry=Unable to display the entry

Added: directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/messages_de.properties?rev=1669604&view=auto
==============================================================================
--- directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/messages_de.properties (added)
+++ directory/studio/trunk/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/messages_de.properties Fri Mar 27 15:27:27 2015
@@ -0,0 +1,28 @@
+# 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.
+LdifEditorPage.LDIFEditor=LDIF-Editor
+
+TableEditorPage.TableEditor=Tabellen-Editor
+
+TableEditorPageActionGroup.Advanced=Erweitert
+TableEditorPageActionGroup.OpenSchemaBrowser=\u00D6ffne Schema Browser
+TableEditorPageActionGroup.ShowIn  =Anzeigen in
+
+TemplateEditorWidget.NoEntrySelected=Kein Eintrag ausgew\u00E4hlt
+TemplateEditorWidget.NoTemplateIsMatchingThisEntry=Kein passendes Template f\u00FCr diesen Eintrag
+TemplateEditorWidget.TemplateEditor =Template-Editor
+TemplateEditorWidget.UnableToDisplayTheEntry=Der Eintrag kann nicht angezeigt werden



Mime
View raw message