You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2007/02/19 22:37:31 UTC
svn commit: r509339 [3/3] - in
/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui:
actions/ editors/entry/ editors/searchresult/ views/browser/
views/connection/ widgets/browser/ widgets/connectio...
Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/connection/ConnectionActionGroup.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/connection/ConnectionActionGroup.java?view=diff&rev=509339&r1=509338&r2=509339
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/connection/ConnectionActionGroup.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/connection/ConnectionActionGroup.java Mon Feb 19 13:37:30 2007
@@ -33,8 +33,8 @@
import org.apache.directory.ldapstudio.browser.ui.actions.PasteAction;
import org.apache.directory.ldapstudio.browser.ui.actions.PropertiesAction;
import org.apache.directory.ldapstudio.browser.ui.actions.RenameAction;
-import org.apache.directory.ldapstudio.browser.ui.actions.proxy.ConnectionViewActionProxy;
import org.apache.directory.ldapstudio.browser.ui.actions.proxy.BrowserActionProxy;
+import org.apache.directory.ldapstudio.browser.ui.actions.proxy.ConnectionViewActionProxy;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
@@ -49,64 +49,84 @@
import org.eclipse.ui.commands.ICommandService;
+/**
+ * This class manages all the actions of the connection widget.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
public class ConnectionActionGroup implements IMenuListener
{
+ /** The Constant newConnectionAction. */
protected static final String newConnectionAction = "newConnectionAction";
+ /** The Constant openConnectionAction. */
protected static final String openConnectionAction = "openConnectionAction";
+ /** The Constant closeConnectionAction. */
protected static final String closeConnectionAction = "closeConnectionAction";
+ /** The Constant copyConnectionAction. */
protected static final String copyConnectionAction = "copyConnectionAction";
+ /** The Constant pasteConnectionAction. */
protected static final String pasteConnectionAction = "pasteConnectionAction";
+ /** The Constant deleteConnectionAction. */
protected static final String deleteConnectionAction = "deleteConnectionAction";
+ /** The Constant renameConnectionAction. */
protected static final String renameConnectionAction = "renameConnectionAction";
+ /** The Constant propertyDialogAction. */
protected static final String propertyDialogAction = "propertyDialogAction";
- protected Map connectionActionMap;
+ /** The action map. */
+ protected Map<String, ConnectionViewActionProxy> connectionActionMap;
+ /** The action bars. */
protected IActionBars actionBars;
+ /** The connection main widget. */
protected ConnectionWidget mainWidget;
+ /**
+ * Creates a new instance of ConnectionActionGroup.
+ *
+ * @param mainWidget the connection main widget
+ * @param configuration the connection widget configuration
+ */
public ConnectionActionGroup( ConnectionWidget mainWidget, ConnectionConfiguration configuration )
{
this.mainWidget = mainWidget;
- this.connectionActionMap = new HashMap();
- TableViewer viewer = mainWidget.getViewer();
+ this.connectionActionMap = new HashMap<String, ConnectionViewActionProxy>();
- this.connectionActionMap.put( newConnectionAction, new ConnectionViewActionProxy( viewer,
- new NewConnectionAction() ) );
- this.connectionActionMap.put( openConnectionAction, new ConnectionViewActionProxy( viewer,
+ TableViewer viewer = mainWidget.getViewer();
+ connectionActionMap
+ .put( newConnectionAction, new ConnectionViewActionProxy( viewer, new NewConnectionAction() ) );
+ connectionActionMap.put( openConnectionAction, new ConnectionViewActionProxy( viewer,
new OpenConnectionAction() ) );
- this.connectionActionMap.put( closeConnectionAction, new ConnectionViewActionProxy( viewer,
+ connectionActionMap.put( closeConnectionAction, new ConnectionViewActionProxy( viewer,
new CloseConnectionAction() ) );
- this.connectionActionMap
- .put( pasteConnectionAction, new ConnectionViewActionProxy( viewer, new PasteAction() ) );
- this.connectionActionMap.put( copyConnectionAction, new ConnectionViewActionProxy( viewer, new CopyAction(
- ( BrowserActionProxy ) this.connectionActionMap.get( pasteConnectionAction ) ) ) );
- this.connectionActionMap.put( deleteConnectionAction,
- new ConnectionViewActionProxy( viewer, new DeleteAction() ) );
- this.connectionActionMap.put( renameConnectionAction,
- new ConnectionViewActionProxy( viewer, new RenameAction() ) );
- this.connectionActionMap.put( propertyDialogAction, new ConnectionViewActionProxy( viewer,
- new PropertiesAction() ) );
-
+ connectionActionMap.put( pasteConnectionAction, new ConnectionViewActionProxy( viewer, new PasteAction() ) );
+ connectionActionMap.put( copyConnectionAction, new ConnectionViewActionProxy( viewer, new CopyAction(
+ ( BrowserActionProxy ) connectionActionMap.get( pasteConnectionAction ) ) ) );
+ connectionActionMap.put( deleteConnectionAction, new ConnectionViewActionProxy( viewer, new DeleteAction() ) );
+ connectionActionMap.put( renameConnectionAction, new ConnectionViewActionProxy( viewer, new RenameAction() ) );
+ connectionActionMap.put( propertyDialogAction, new ConnectionViewActionProxy( viewer, new PropertiesAction() ) );
}
+ /**
+ * Disposes this action group.
+ */
public void dispose()
{
- if ( this.mainWidget != null )
+ if ( mainWidget != null )
{
-
- for ( Iterator it = this.connectionActionMap.keySet().iterator(); it.hasNext(); )
+ for ( Iterator it = connectionActionMap.keySet().iterator(); it.hasNext(); )
{
String key = ( String ) it.next();
ConnectionViewActionProxy action = ( ConnectionViewActionProxy ) this.connectionActionMap.get( key );
@@ -114,35 +134,48 @@
action = null;
it.remove();
}
- this.connectionActionMap.clear();
- this.connectionActionMap = null;
+ connectionActionMap.clear();
+ connectionActionMap = null;
- this.actionBars = null;
- this.mainWidget = null;
+ actionBars = null;
+ mainWidget = null;
}
}
+ /**
+ * Enables the action handlers.
+ *
+ * @param actionBars the action bars
+ */
public void enableGlobalActionHandlers( IActionBars actionBars )
{
this.actionBars = actionBars;
- this.activateGlobalActionHandlers();
+ activateGlobalActionHandlers();
}
+ /**
+ * Fills the tool bar.
+ *
+ * @param toolBarManager the tool bar manager
+ */
public void fillToolBar( IToolBarManager toolBarManager )
{
-
toolBarManager.add( ( IAction ) this.connectionActionMap.get( newConnectionAction ) );
toolBarManager.add( new Separator() );
toolBarManager.add( ( IAction ) this.connectionActionMap.get( openConnectionAction ) );
toolBarManager.add( ( IAction ) this.connectionActionMap.get( closeConnectionAction ) );
toolBarManager.update( true );
-
}
+ /**
+ * Fills the local menu.
+ *
+ * @param menuManager the local menu manager
+ */
public void fillMenu( IMenuManager menuManager )
{
// menuManager.add(this.openSortDialogAction);
@@ -151,6 +184,11 @@
}
+ /**
+ * Fills the context menu.
+ *
+ * @param menuManager the context menu manager
+ */
public void fillContextMenu( IMenuManager menuManager )
{
menuManager.setRemoveAllWhenShown( true );
@@ -158,52 +196,62 @@
}
+ /**
+ * {@inheritDoc}
+ *
+ * This implementation fills the context menu.
+ */
public void menuAboutToShow( IMenuManager menuManager )
{
-
// add
- menuManager.add( ( IAction ) this.connectionActionMap.get( newConnectionAction ) );
+ menuManager.add( ( IAction ) connectionActionMap.get( newConnectionAction ) );
menuManager.add( new Separator() );
// open/close
- if ( ( ( IAction ) this.connectionActionMap.get( closeConnectionAction ) ).isEnabled() )
- menuManager.add( ( IAction ) this.connectionActionMap.get( closeConnectionAction ) );
- else if ( ( ( IAction ) this.connectionActionMap.get( openConnectionAction ) ).isEnabled() )
- menuManager.add( ( IAction ) this.connectionActionMap.get( openConnectionAction ) );
+ if ( ( ( IAction ) connectionActionMap.get( closeConnectionAction ) ).isEnabled() )
+ {
+ menuManager.add( ( IAction ) connectionActionMap.get( closeConnectionAction ) );
+ }
+ else if ( ( ( IAction ) connectionActionMap.get( openConnectionAction ) ).isEnabled() )
+ {
+ menuManager.add( ( IAction ) connectionActionMap.get( openConnectionAction ) );
+ }
menuManager.add( new Separator() );
// copy/paste/...
- menuManager.add( ( IAction ) this.connectionActionMap.get( copyConnectionAction ) );
- menuManager.add( ( IAction ) this.connectionActionMap.get( pasteConnectionAction ) );
- menuManager.add( ( IAction ) this.connectionActionMap.get( deleteConnectionAction ) );
- menuManager.add( ( IAction ) this.connectionActionMap.get( renameConnectionAction ) );
+ menuManager.add( ( IAction ) connectionActionMap.get( copyConnectionAction ) );
+ menuManager.add( ( IAction ) connectionActionMap.get( pasteConnectionAction ) );
+ menuManager.add( ( IAction ) connectionActionMap.get( deleteConnectionAction ) );
+ menuManager.add( ( IAction ) connectionActionMap.get( renameConnectionAction ) );
menuManager.add( new Separator() );
// additions
menuManager.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
// properties
- menuManager.add( ( IAction ) this.connectionActionMap.get( propertyDialogAction ) );
+ menuManager.add( ( IAction ) connectionActionMap.get( propertyDialogAction ) );
}
+ /**
+ * Activates the action handlers.
+ */
public void activateGlobalActionHandlers()
{
-
ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
ICommandService.class );
- if ( this.actionBars != null )
+ if ( actionBars != null )
{
- actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), ( IAction ) this.connectionActionMap
+ actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), ( IAction ) connectionActionMap
.get( copyConnectionAction ) );
- actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(), ( IAction ) this.connectionActionMap
+ actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(), ( IAction ) connectionActionMap
.get( pasteConnectionAction ) );
- actionBars.setGlobalActionHandler( ActionFactory.DELETE.getId(), ( IAction ) this.connectionActionMap
+ actionBars.setGlobalActionHandler( ActionFactory.DELETE.getId(), ( IAction ) connectionActionMap
.get( deleteConnectionAction ) );
- actionBars.setGlobalActionHandler( ActionFactory.RENAME.getId(), ( IAction ) this.connectionActionMap
+ actionBars.setGlobalActionHandler( ActionFactory.RENAME.getId(), ( IAction ) connectionActionMap
.get( renameConnectionAction ) );
- actionBars.setGlobalActionHandler( ActionFactory.PROPERTIES.getId(), ( IAction ) this.connectionActionMap
+ actionBars.setGlobalActionHandler( ActionFactory.PROPERTIES.getId(), ( IAction ) connectionActionMap
.get( propertyDialogAction ) );
actionBars.updateActionBars();
}
@@ -211,35 +259,36 @@
{
if ( commandService != null )
{
- IAction ca = ( IAction ) this.connectionActionMap.get( copyConnectionAction );
+ IAction ca = ( IAction ) connectionActionMap.get( copyConnectionAction );
ca.setActionDefinitionId( "org.apache.directory.ldapstudio.browser.action.copy" );
commandService.getCommand( ca.getActionDefinitionId() ).setHandler( new ActionHandler( ca ) );
- IAction pa = ( IAction ) this.connectionActionMap.get( pasteConnectionAction );
+ IAction pa = ( IAction ) connectionActionMap.get( pasteConnectionAction );
pa.setActionDefinitionId( "org.apache.directory.ldapstudio.browser.action.paste" );
commandService.getCommand( pa.getActionDefinitionId() ).setHandler( new ActionHandler( pa ) );
- IAction da = ( IAction ) this.connectionActionMap.get( deleteConnectionAction );
+ IAction da = ( IAction ) connectionActionMap.get( deleteConnectionAction );
da.setActionDefinitionId( "org.apache.directory.ldapstudio.browser.action.delete" );
commandService.getCommand( da.getActionDefinitionId() ).setHandler( new ActionHandler( da ) );
- IAction pda = ( IAction ) this.connectionActionMap.get( propertyDialogAction );
+ IAction pda = ( IAction ) connectionActionMap.get( propertyDialogAction );
pda.setActionDefinitionId( "org.apache.directory.ldapstudio.browser.action.properties" );
commandService.getCommand( pda.getActionDefinitionId() ).setHandler( new ActionHandler( pda ) );
}
}
-
}
+ /**
+ * Deactivates the action handlers.
+ */
public void deactivateGlobalActionHandlers()
{
-
ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
ICommandService.class );
- if ( this.actionBars != null )
+ if ( actionBars != null )
{
actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), null );
actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(), null );
@@ -252,16 +301,16 @@
{
if ( commandService != null )
{
- IAction ca = ( IAction ) this.connectionActionMap.get( copyConnectionAction );
+ IAction ca = ( IAction ) connectionActionMap.get( copyConnectionAction );
commandService.getCommand( ca.getActionDefinitionId() ).setHandler( null );
- IAction pa = ( IAction ) this.connectionActionMap.get( pasteConnectionAction );
+ IAction pa = ( IAction ) connectionActionMap.get( pasteConnectionAction );
commandService.getCommand( pa.getActionDefinitionId() ).setHandler( null );
- IAction da = ( IAction ) this.connectionActionMap.get( deleteConnectionAction );
+ IAction da = ( IAction ) connectionActionMap.get( deleteConnectionAction );
commandService.getCommand( da.getActionDefinitionId() ).setHandler( null );
- IAction pda = ( IAction ) this.connectionActionMap.get( propertyDialogAction );
+ IAction pda = ( IAction ) connectionActionMap.get( propertyDialogAction );
commandService.getCommand( pda.getActionDefinitionId() ).setHandler( null );
}
Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EntryEditorWidgetUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EntryEditorWidgetUniversalListener.java?view=diff&rev=509339&r1=509338&r2=509339
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EntryEditorWidgetUniversalListener.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EntryEditorWidgetUniversalListener.java Mon Feb 19 13:37:30 2007
@@ -33,120 +33,168 @@
import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
import org.apache.directory.ldapstudio.browser.core.model.IValue;
import org.apache.directory.ldapstudio.browser.ui.actions.SelectionUtils;
-
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+/**
+ * The EntryEditorWidgetUniversalListener manages all events for the entry editor widget.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
public class EntryEditorWidgetUniversalListener implements EntryUpdateListener
{
+ /** The tree viewer */
protected TreeViewer viewer;
+ /** The action used to start the default value editor */
protected OpenDefaultEditorAction startEditAction;
-
- public EntryEditorWidgetUniversalListener( TreeViewer treeViewer, OpenDefaultEditorAction startEditAction )
+ /** This listener starts the value editor when pressing enter */
+ protected SelectionListener viewerSelectionListener = new SelectionAdapter()
{
- this.startEditAction = startEditAction;
- this.viewer = treeViewer;
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetSelected( SelectionEvent e )
+ {
+ }
- this.initListeners();
- }
+ /**
+ * {@inheritDoc}
+ *
+ * This implementation starts the value editor.
+ */
+ public void widgetDefaultSelected( SelectionEvent e )
+ {
+ if ( startEditAction.isEnabled() )
+ startEditAction.run();
+ }
+ };
- protected void initListeners()
+ /** This listener starts the value editor or expands/collapses the selected attribute */
+ protected MouseListener viewerMouseListener = new MouseAdapter()
{
-
- this.viewer.getTree().addSelectionListener( new SelectionAdapter()
+ /**
+ * {@inheritDoc}
+ *
+ * This implementation starts the value editor or expands/collapses the selected attribute.
+ */
+ public void mouseDoubleClick( MouseEvent e )
{
- public void widgetSelected( SelectionEvent e )
+ if ( startEditAction.isEnabled() )
{
+ startEditAction.run();
}
-
- public void widgetDefaultSelected( SelectionEvent e )
+ IAttribute[] attributes = SelectionUtils.getAttributes( viewer.getSelection() );
+ IValue[] values = SelectionUtils.getValues( viewer.getSelection() );
+ if ( attributes.length == 1 && values.length == 0 )
{
- if ( startEditAction.isEnabled() )
- startEditAction.run();
- }
- } );
- this.viewer.getTree().addMouseListener( new MouseAdapter()
- {
- public void mouseDoubleClick( MouseEvent e )
- {
- if ( startEditAction.isEnabled() )
- startEditAction.run();
-
- IAttribute[] attributes = SelectionUtils.getAttributes( viewer.getSelection() );
- IValue[] values = SelectionUtils.getValues( viewer.getSelection() );
- if ( attributes.length == 1 && values.length == 0 )
+ if ( viewer.getExpandedState( attributes[0] ) )
{
- if ( viewer.getExpandedState( attributes[0] ) )
- viewer.collapseToLevel( attributes[0], 1 );
- else
- viewer.expandToLevel( attributes[0], 1 );
+ viewer.collapseToLevel( attributes[0], 1 );
+ }
+ else
+ {
+ viewer.expandToLevel( attributes[0], 1 );
}
}
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public void mouseDown( MouseEvent e )
+ {
+ }
- public void mouseDown( MouseEvent e )
- {
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void mouseUp( MouseEvent e )
+ {
+ }
+ };
- public void mouseUp( MouseEvent e )
- {
- }
- } );
+ /**
+ * Creates a new instance of EntryEditorWidgetUniversalListener.
+ *
+ * @param treeViewer the tree viewer
+ * @param startEditAction the action used to start the default value editor
+ */
+ public EntryEditorWidgetUniversalListener( TreeViewer treeViewer, OpenDefaultEditorAction startEditAction )
+ {
+ this.startEditAction = startEditAction;
+ this.viewer = treeViewer;
+ // register listeners
+ viewer.getTree().addSelectionListener( viewerSelectionListener );
+ viewer.getTree().addMouseListener( viewerMouseListener );
EventRegistry.addEntryUpdateListener( this );
}
+ /**
+ * Disposes this universal listener.
+ */
public void dispose()
{
- if ( this.viewer != null )
+ if ( viewer != null )
{
EventRegistry.removeEntryUpdateListener( this );
- this.startEditAction = null;
- this.viewer = null;
+ startEditAction = null;
+ viewer = null;
}
}
+ /**
+ * {@inheritDoc}
+ *
+ * This implementation refreshes the viewer and selects a value depending
+ * on the event.
+ */
public void entryUpdated( EntryModificationEvent event )
{
- if ( this.viewer == null || this.viewer.getTree() == null || this.viewer.getTree().isDisposed()
- || this.viewer.getInput() == null || event.getModifiedEntry() != this.viewer.getInput() )
+ if ( viewer == null || viewer.getTree() == null || viewer.getTree().isDisposed()
+ || viewer.getInput() == null || event.getModifiedEntry() != viewer.getInput() )
{
return;
}
// force closing of cell editors
- if ( this.viewer.isCellEditorActive() )
+ if ( viewer.isCellEditorActive() )
{
- this.viewer.cancelEditing();
+ viewer.cancelEditing();
}
// refresh
- this.viewer.refresh();
+ viewer.refresh();
- // restore selection
+ // selection value
if ( event instanceof ValueAddedEvent )
{
+ // select the vadded value
ValueAddedEvent vaEvent = ( ValueAddedEvent ) event;
viewer.setSelection( new StructuredSelection( vaEvent.getAddedValue() ), true );
- this.viewer.refresh();
+ viewer.refresh();
}
else if ( event instanceof ValueDeletedEvent )
{
+ // select another value of the deleted attribute
ValueDeletedEvent vdEvent = ( ValueDeletedEvent ) event;
if ( viewer.getSelection().isEmpty() && vdEvent.getDeletedValue().getAttribute().getValueSize() > 0 )
{
@@ -156,6 +204,7 @@
}
else if ( event instanceof EmptyValueAddedEvent )
{
+ // select the added value and start editing
EmptyValueAddedEvent evaEvent = ( EmptyValueAddedEvent ) event;
viewer.setSelection( new StructuredSelection( evaEvent.getAddedValue() ), true );
if ( startEditAction.isEnabled() )
@@ -165,6 +214,7 @@
}
else if ( event instanceof EmptyValueDeletedEvent )
{
+ // select another value of the deleted attribute
EmptyValueDeletedEvent evdEvent = ( EmptyValueDeletedEvent ) event;
if ( viewer.getSelection().isEmpty() && evdEvent.getDeletedValue().getAttribute().getValueSize() > 0 )
{
@@ -174,11 +224,13 @@
}
else if ( event instanceof ValueModifiedEvent )
{
+ // select the modified value
ValueModifiedEvent vmEvent = ( ValueModifiedEvent ) event;
viewer.setSelection( new StructuredSelection( vmEvent.getNewValue() ), true );
}
else if ( event instanceof ValueRenamedEvent )
{
+ // select the renamed value
ValueRenamedEvent vrEvent = ( ValueRenamedEvent ) event;
viewer.setSelection( new StructuredSelection( vrEvent.getNewValue() ), true );
}