directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r804250 - in /directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui: actions/ views/browser/
Date Fri, 14 Aug 2009 15:02:49 GMT
Author: pamarcelot
Date: Fri Aug 14 15:02:48 2009
New Revision: 804250

URL: http://svn.apache.org/viewvc?rev=804250&view=rev
Log:
DIRSTUDIO-516:
o Added a new OpenEntryEditorAction
o Added a new EntryEditorMenuManager that displays sub-menu in the context menu of the browser
view with all the available entry editors.

Added:
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/EntryEditorMenuManager.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenEntryEditorAction.java
Modified:
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/LocateEntryInDitAction.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/messages.properties
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewActionGroup.java

Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/EntryEditorMenuManager.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/EntryEditorMenuManager.java?rev=804250&view=auto
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/EntryEditorMenuManager.java
(added)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/EntryEditorMenuManager.java
Fri Aug 14 15:02:48 2009
@@ -0,0 +1,119 @@
+package org.apache.directory.studio.ldapbrowser.ui.actions;
+
+
+import java.util.Collection;
+
+import org.apache.directory.studio.entryeditors.EntryEditorExtension;
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils;
+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.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+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.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.ui.PlatformUI;
+
+
+public class EntryEditorMenuManager extends MenuManager implements IMenuListener
+{
+    protected ISelectionProvider selectionProvider;
+
+
+    /**
+     * Creates a menu manager.  The text and id are <code>null</code>.
+     * Typically used for creating a context menu, where it doesn't need to be referred to
by id.
+     */
+    public EntryEditorMenuManager( ISelectionProvider selectionProvider )
+    {
+        super( "Open With" );
+        this.selectionProvider = selectionProvider;
+        addMenuListener( this );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
+     */
+    public void menuAboutToShow( IMenuManager manager )
+    {
+        // As the Menu Manager is dynamic, we need to 
+        // remove all the previously added actions
+        removeAll();
+
+        // Getting the entry editors and creating an action for each
+        Collection<EntryEditorExtension> entryEditors = BrowserUIPlugin.getDefault().getEntryEditorManager()
+            .getSortedEntryEditorExtensions();
+        for ( EntryEditorExtension entryEditorExtension : entryEditors )
+        {
+            add( createAction( entryEditorExtension ) );
+        }
+
+        // Separator
+        add( new Separator() );
+
+        // Preferences Action
+        add( new Action( "Preferences..." )
+        {
+        } );
+    }
+
+
+    /**
+     * Creates an action for the given entry editor.
+     *
+     * @param entryEditorExtension
+     *      the entry editor
+     * @return
+     *      an action associated with the entry editor
+     */
+    private IAction createAction( EntryEditorExtension entryEditorExtension )
+    {
+        final EntryEditorExtension entryEditorExtension2 = entryEditorExtension;
+        Action action = new Action( entryEditorExtension.getName() )
+        {
+            public void run()
+            {
+                MessageDialog.openInformation( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+                    entryEditorExtension2.getName(), "Instead of this window, the \"" + entryEditorExtension2.getName()
+                        + "\" entry editor should be opened." );
+            }
+        };
+
+        // TODO Add enable/disable action if the entry editor can "handle" the entry.
+        // TODO Or do include this entry editor in the list of available entry editors.
+        //action.setEnabled( false );
+
+        return action;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isVisible()
+    {
+        ISelection selection = selectionProvider.getSelection();
+
+        IBookmark[] selectedBookMarks = BrowserSelectionUtils.getBookmarks( selection );
+        IEntry[] selectedEntries = BrowserSelectionUtils.getEntries( selection );
+        ISearchResult[] selectedSearchResults = BrowserSelectionUtils.getSearchResults( selection
);
+
+        return ( selectedSearchResults.length + selectedBookMarks.length + selectedEntries.length
== 1 );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isDynamic()
+    {
+        return true;
+    }
+}

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/LocateEntryInDitAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/LocateEntryInDitAction.java?rev=804250&r1=804249&r2=804250&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/LocateEntryInDitAction.java
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/LocateEntryInDitAction.java
Fri Aug 14 15:02:48 2009
@@ -52,7 +52,7 @@
         if ( getSelectedSearchResults().length == 1
             && getSelectedBookmarks().length + getSelectedEntries().length + getSelectedBrowserViewCategories().length
== 0 )
         {
-            return Messages.getString( "LocateEntryInDitAction.openSearchResult" ); //$NON-NLS-1$
+            return Messages.getString( "LocateEntryInDitAction.OpenSearchResult" ); //$NON-NLS-1$
         }
         else if ( getSelectedBookmarks().length == 1
             && getSelectedSearchResults().length + getSelectedEntries().length

Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenEntryEditorAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenEntryEditorAction.java?rev=804250&view=auto
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenEntryEditorAction.java
(added)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenEntryEditorAction.java
Fri Aug 14 15:02:48 2009
@@ -0,0 +1,106 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.actions;
+
+
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * This class implements the Open Entry Editor Action.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class OpenEntryEditorAction extends BrowserAction
+{
+
+    /**
+     * Creates a new instance of OpenEntryEditorAction.
+     */
+    public OpenEntryEditorAction()
+    {
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        MessageDialog.openInformation( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+            "Open Entry Editor", "Instead of this window, the entry editor should be opened."
);
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        if ( getSelectedSearchResults().length == 1
+            && getSelectedBookmarks().length + getSelectedEntries().length + getSelectedBrowserViewCategories().length
== 0 )
+        {
+            return Messages.getString( "OpenEntryEditorAction.OpenSearchResult" ); //$NON-NLS-1$
+        }
+        else if ( getSelectedBookmarks().length == 1
+            && getSelectedSearchResults().length + getSelectedEntries().length
+                + getSelectedBrowserViewCategories().length == 0 )
+        {
+            return Messages.getString( "OpenEntryEditorAction.OpenBookmark" ); //$NON-NLS-1$
+        }
+        else
+        {
+            return Messages.getString( "OpenEntryEditorAction.OpenEntry" ); //$NON-NLS-1$
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        return getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length
== 1
+            || getSelectedAttributes().length + getSelectedValues().length > 0;
+    }
+}

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/messages.properties?rev=804250&r1=804249&r2=804250&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/messages.properties
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/messages.properties
Fri Aug 14 15:02:48 2009
@@ -59,7 +59,7 @@
 LocateDnInDitAction.LocateDN=Locate DN in DIT
 LocateEntryInDitAction.OpenBookmark=Open Bookmark in DIT
 LocateEntryInDitAction.OpenEntry=Open Entry in DIT
-LocateEntryInDitAction.openSearchResult=Open Search Result in DIT
+LocateEntryInDitAction.OpenSearchResult=Open Search Result in DIT
 MoveAction.Move=Move...
 MoveAction.MoveEntries=Move Entries...
 MoveAction.MoveEntry=Move Entry...
@@ -79,3 +79,7 @@
 OpenSchemaBrowserAction.SyntaxDescription=Syntax Description
 OpenSearchAction.Search=Search...
 OpenSearchResultAction.OpenResult=Open Search Result
+
+OpenEntryEditorAction.OpenBookmark=Open Bookmark
+OpenEntryEditorAction.OpenEntry=Open Entry
+OpenEntryEditorAction.OpenSearchResult=Open Search Result

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewActionGroup.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewActionGroup.java?rev=804250&r1=804249&r2=804250&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewActionGroup.java
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewActionGroup.java
Fri Aug 14 15:02:48 2009
@@ -33,6 +33,7 @@
 import org.apache.directory.studio.ldapbrowser.ui.actions.CopyEntryAsCsvAction;
 import org.apache.directory.studio.ldapbrowser.ui.actions.CopyEntryAsLdifAction;
 import org.apache.directory.studio.ldapbrowser.ui.actions.CopyUrlAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.EntryEditorMenuManager;
 import org.apache.directory.studio.ldapbrowser.ui.actions.GotoDnAction;
 import org.apache.directory.studio.ldapbrowser.ui.actions.ImportExportAction;
 import org.apache.directory.studio.ldapbrowser.ui.actions.LocateEntryInDitAction;
@@ -41,6 +42,7 @@
 import org.apache.directory.studio.ldapbrowser.ui.actions.NewBookmarkAction;
 import org.apache.directory.studio.ldapbrowser.ui.actions.NewEntryAction;
 import org.apache.directory.studio.ldapbrowser.ui.actions.NewSearchAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.OpenEntryEditorAction;
 import org.apache.directory.studio.utils.ActionUtils;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IMenuManager;
@@ -162,10 +164,13 @@
 
     /** The Constant exportOdfAction. */
     private static final String exportOdfAction = "exportOdfAction"; //$NON-NLS-1$
-    
+
     /** The Constant fetchOperationalAttributesAction. */
     private static final String fetchOperationalAttributesAction = "fetchOperationalAttributesAction";
//$NON-NLS-1$
 
+    /** The Constant openEntryEditorAction. */
+    private static final String openEntryEditorAction = "openEntryEditor"; //$NON-NLS-1$
+
 
     /**
      * Creates a new instance of BrowserViewActionGroup and 
@@ -240,6 +245,8 @@
 
         browserActionMap.put( fetchOperationalAttributesAction, new BrowserViewActionProxy(
viewer,
             new FetchOperationalAttributesAction() ) );
+
+        browserActionMap.put( openEntryEditorAction, new BrowserViewActionProxy( viewer,
new OpenEntryEditorAction() ) );
     }
 
 
@@ -311,6 +318,9 @@
         menuManager.add( new Separator() );
 
         // navigation
+        menuManager.add( browserActionMap.get( openEntryEditorAction ) );
+        MenuManager openWithEntryEditorMenuManager = new EntryEditorMenuManager( mainWidget.getViewer()
);
+        menuManager.add( openWithEntryEditorMenuManager );
         BrowserViewActionProxy leid = ( BrowserViewActionProxy ) browserActionMap.get( locateEntryInDitAction
);
         leid.setImageDescriptor( leid.getAction().getImageDescriptor() );
         menuManager.add( leid );



Mime
View raw message