Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 53293 invoked from network); 18 Dec 2006 17:55:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Dec 2006 17:55:32 -0000 Received: (qmail 87298 invoked by uid 500); 18 Dec 2006 17:55:39 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 87268 invoked by uid 500); 18 Dec 2006 17:55:39 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 87257 invoked by uid 99); 18 Dec 2006 17:55:39 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Dec 2006 09:55:39 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Dec 2006 09:55:25 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 66C3C1A9885; Mon, 18 Dec 2006 09:53:45 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r488368 [22/23] - in /directory/sandbox/pamarcelot/ldapstudio: ldapstudio-browser-ui/ ldapstudio-browser-ui/META-INF/ ldapstudio-browser-ui/about_files/ ldapstudio-browser-ui/icons/ ldapstudio-browser-ui/icons/ovr16/ ldapstudio-browser-ui/s... Date: Mon, 18 Dec 2006 17:53:22 -0000 To: commits@directory.apache.org From: pamarcelot@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061218175345.66C3C1A9885@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/AttributesViewController.java URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/AttributesViewController.java?view=diff&rev=488368&r1=488367&r2=488368 ============================================================================== --- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/AttributesViewController.java (original) +++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/AttributesViewController.java Mon Dec 18 09:52:58 2006 @@ -20,6 +20,7 @@ package org.apache.directory.ldapstudio.browser.controller; + import org.apache.directory.ldapstudio.browser.controller.actions.AttributeDeleteAction; import org.apache.directory.ldapstudio.browser.controller.actions.AttributeEditAction; import org.apache.directory.ldapstudio.browser.controller.actions.AttributeNewAction; @@ -41,12 +42,14 @@ import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.IWorkbenchPart; + /** * This class is the Controller for the Attributes View. * * @author Apache Directory Project */ -public class AttributesViewController implements IMenuListener { +public class AttributesViewController implements IMenuListener +{ private static final AttributesViewController instance; /** The controlled View */ @@ -59,173 +62,200 @@ private static IAction attributeDeleteAction; // Static thread-safe singleton initializer - static { - try { - instance = new AttributesViewController(); - } catch (Throwable e) { - throw new RuntimeException(e.getMessage()); - } + static + { + try + { + instance = new AttributesViewController(); + } + catch ( Throwable e ) + { + throw new RuntimeException( e.getMessage() ); + } } - /** - * Use this method to get the singleton instance of the controller - * - * @return - */ - public static AttributesViewController getInstance() { - return instance; - } /** - * Sets the controlled View - * - * @param view - * the controlled View - */ - public void setView(final AttributesView view) { - this.view = view; - - // Handling selection of the Browser View to update this view - view.getSite().getPage().addSelectionListener(BrowserView.ID, - new ISelectionListener() { - public void selectionChanged(IWorkbenchPart part, - ISelection selection) { - // Setting the new input - view.setInput(((TreeSelection) selection) - .getFirstElement()); - - // Resizing columns to fit - view.resizeColumsToFit(); - } - }); - - // Handling the double click modification - view.getViewer().getTree().addSelectionListener(new SelectionAdapter() { - public void widgetDefaultSelected(SelectionEvent e) { - new RenameAttributeAction(view, "Rename attribute").run(); - } - }); + * Use this method to get the singleton instance of the controller + * + * @return + */ + public static AttributesViewController getInstance() + { + return instance; } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) - */ - public void menuAboutToShow(IMenuManager manager) { - manager.add(attributeNewAction); - manager.add(attributeEditAction); - manager.add(attributeDeleteAction); - } - - /** - * Creates all the actions - */ - public void createActions() { - // Creating Actions - attributeNewAction = new AttributeNewAction(view, "New attribute"); - attributeEditAction = new AttributeEditAction(view, "Edit attribute"); - attributeDeleteAction = new AttributeDeleteAction(view, - "Delete attribute"); - - // Disabling Actions by default - attributeNewAction.setEnabled(false); - attributeEditAction.setEnabled(false); - attributeDeleteAction.setEnabled(false); - - registerUpdateActions(); - } /** - * Registers a Listener on the Browser View and enable/disable the - * Actions according to the selection - */ - private void registerUpdateActions() { - // Handling selection of the Browser View to enable/disable the Actions - view.getSite().getPage().addSelectionListener(BrowserView.ID, - new ISelectionListener() { - public void selectionChanged(IWorkbenchPart part, - ISelection selection) { - Object selectedObject = ((TreeSelection) selection) - .getFirstElement(); - Tree tree = view.getViewer().getTree(); - - if (selectedObject == null) { - attributeNewAction.setEnabled(false); - tree.setEnabled(false); - } else { - if (selectedObject instanceof ConnectionWrapper) { - attributeNewAction.setEnabled(false); - tree.setEnabled(false); - } else if (selectedObject instanceof EntryWrapper) { - attributeNewAction.setEnabled(true); - tree.setEnabled(true); - } - } - } - }); - - // Handling selection of thencoree Attributes View to enable/disable the - // Actions - view.getSite().getPage().addSelectionListener(AttributesView.ID, - new ISelectionListener() { - public void selectionChanged(IWorkbenchPart part, - ISelection selection) { - if (selection.isEmpty()) { - attributeEditAction.setEnabled(false); - attributeDeleteAction.setEnabled(false); - } else { - if (((StructuredSelection) selection).size() == 1) { - attributeEditAction.setEnabled(true); - if (attributeDeleteAction.getText().equals( - "Delete attributes")) { - attributeDeleteAction - .setText("Delete attribute"); - attributeDeleteAction - .setToolTipText("Delete attribute"); - } - } else { - attributeEditAction.setEnabled(false); - if (attributeDeleteAction.getText().equals( - "Delete attribute")) { - attributeDeleteAction - .setText("Delete attributes"); - attributeDeleteAction - .setToolTipText("Delete attributes"); - } - } - - attributeDeleteAction.setEnabled(true); - } - } - }); + * Sets the controlled View + * + * @param view + * the controlled View + */ + public void setView( final AttributesView view ) + { + this.view = view; + + // Handling selection of the Browser View to update this view + view.getSite().getPage().addSelectionListener( BrowserView.ID, new ISelectionListener() + { + public void selectionChanged( IWorkbenchPart part, ISelection selection ) + { + // Setting the new input + view.setInput( ( ( TreeSelection ) selection ).getFirstElement() ); + + // Resizing columns to fit + view.resizeColumsToFit(); + } + } ); + + // Handling the double click modification + view.getViewer().getTree().addSelectionListener( new SelectionAdapter() + { + public void widgetDefaultSelected( SelectionEvent e ) + { + new RenameAttributeAction( view, "Rename attribute" ).run(); + } + } ); } - /** - * Gets the AttibuteNewAction - * - * @return the AttibuteNewAction - */ - public IAction getAttributeNewAction() { - return attributeNewAction; - } - /** - * Gets the AttributeEditAction - * - * @return the AttributeEditAction - */ - public IAction getAttributeEditAction() { - return attributeEditAction; - } + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) + */ + public void menuAboutToShow( IMenuManager manager ) + { + manager.add( attributeNewAction ); + manager.add( attributeEditAction ); + manager.add( attributeDeleteAction ); + } + + + /** + * Creates all the actions + */ + public void createActions() + { + // Creating Actions + attributeNewAction = new AttributeNewAction( view, "New attribute" ); + attributeEditAction = new AttributeEditAction( view, "Edit attribute" ); + attributeDeleteAction = new AttributeDeleteAction( view, "Delete attribute" ); + + // Disabling Actions by default + attributeNewAction.setEnabled( false ); + attributeEditAction.setEnabled( false ); + attributeDeleteAction.setEnabled( false ); + + registerUpdateActions(); + } + + + /** + * Registers a Listener on the Browser View and enable/disable the + * Actions according to the selection + */ + private void registerUpdateActions() + { + // Handling selection of the Browser View to enable/disable the Actions + view.getSite().getPage().addSelectionListener( BrowserView.ID, new ISelectionListener() + { + public void selectionChanged( IWorkbenchPart part, ISelection selection ) + { + Object selectedObject = ( ( TreeSelection ) selection ).getFirstElement(); + Tree tree = view.getViewer().getTree(); + + if ( selectedObject == null ) + { + attributeNewAction.setEnabled( false ); + tree.setEnabled( false ); + } + else + { + if ( selectedObject instanceof ConnectionWrapper ) + { + attributeNewAction.setEnabled( false ); + tree.setEnabled( false ); + } + else if ( selectedObject instanceof EntryWrapper ) + { + attributeNewAction.setEnabled( true ); + tree.setEnabled( true ); + } + } + } + } ); - /** - * Gets the AttributeDeleteAction - * - * @return the AttributeDeleteAction - */ - public IAction getAttributeDeleteAction() { - return attributeDeleteAction; + // Handling selection of thencoree Attributes View to enable/disable the + // Actions + view.getSite().getPage().addSelectionListener( AttributesView.ID, new ISelectionListener() + { + public void selectionChanged( IWorkbenchPart part, ISelection selection ) + { + if ( selection.isEmpty() ) + { + attributeEditAction.setEnabled( false ); + attributeDeleteAction.setEnabled( false ); + } + else + { + if ( ( ( StructuredSelection ) selection ).size() == 1 ) + { + attributeEditAction.setEnabled( true ); + if ( attributeDeleteAction.getText().equals( "Delete attributes" ) ) + { + attributeDeleteAction.setText( "Delete attribute" ); + attributeDeleteAction.setToolTipText( "Delete attribute" ); + } + } + else + { + attributeEditAction.setEnabled( false ); + if ( attributeDeleteAction.getText().equals( "Delete attribute" ) ) + { + attributeDeleteAction.setText( "Delete attributes" ); + attributeDeleteAction.setToolTipText( "Delete attributes" ); + } + } + + attributeDeleteAction.setEnabled( true ); + } + } + } ); + } + + + /** + * Gets the AttibuteNewAction + * + * @return the AttibuteNewAction + */ + public IAction getAttributeNewAction() + { + return attributeNewAction; + } + + + /** + * Gets the AttributeEditAction + * + * @return the AttributeEditAction + */ + public IAction getAttributeEditAction() + { + return attributeEditAction; + } + + + /** + * Gets the AttributeDeleteAction + * + * @return the AttributeDeleteAction + */ + public IAction getAttributeDeleteAction() + { + return attributeDeleteAction; } } Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/BrowserViewController.java URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/BrowserViewController.java?view=diff&rev=488368&r1=488367&r2=488368 ============================================================================== --- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/BrowserViewController.java (original) +++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/BrowserViewController.java Mon Dec 18 09:52:58 2006 @@ -20,6 +20,7 @@ package org.apache.directory.ldapstudio.browser.controller; + import org.apache.directory.ldapstudio.browser.controller.actions.ConnectionDeleteAction; import org.apache.directory.ldapstudio.browser.controller.actions.ConnectionEditAction; import org.apache.directory.ldapstudio.browser.controller.actions.ConnectionNewAction; @@ -41,12 +42,14 @@ import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.IWorkbenchPart; + /** * This class is the Controller for the Browser View. * * @author Apache Directory Project */ -public class BrowserViewController implements IMenuListener { +public class BrowserViewController implements IMenuListener +{ private static final BrowserViewController instance; /** The controlled view */ @@ -65,166 +68,197 @@ private static IAction entryDeleteAction; // Static thread-safe singleton initializer - static { - try { - instance = new BrowserViewController(); - } catch (Throwable e) { - throw new RuntimeException(e.getMessage()); - } + static + { + try + { + instance = new BrowserViewController(); + } + catch ( Throwable e ) + { + throw new RuntimeException( e.getMessage() ); + } } + /** - * Use this method to get the singleton instance of the controller - * - * @return - */ - public static BrowserViewController getInstance() { - return instance; + * Use this method to get the singleton instance of the controller + * + * @return + */ + public static BrowserViewController getInstance() + { + return instance; } + /* - * (non-Javadoc) - * - * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) - */ - public void menuAboutToShow(IMenuManager manager) { - manager.add(connectionNewAction); - manager.add(connectionEditAction); - manager.add(connectionDeleteAction); - manager.add(new Separator()); - manager.add(refreshAction); - manager.add(new Separator()); - manager.add(entryNewAction); - manager.add(entryDeleteAction); - } - - /** - * Sets the controlled View - * - * @param view - * the controlled View - */ - public void setView(final BrowserView view) { - this.view = view; - - // Adding DoubleClick behavior - view.getViewer().addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - // What we get from the treeViewer is a StructuredSelection - StructuredSelection selection = (StructuredSelection) event - .getSelection(); - - // Here's the real object - Object objectSelection = selection.getFirstElement(); - - view.getViewer().setExpandedState(objectSelection, - !view.getViewer().getExpandedState(objectSelection)); - } - }); - } - - /** - * Creates all the actions - */ - public void createActions() { - connectionNewAction = new ConnectionNewAction(view, "New connection"); - connectionDeleteAction = new ConnectionDeleteAction(view, - "Delete connection"); - connectionEditAction = new ConnectionEditAction(view, "Edit connection"); - refreshAction = new RefreshAction(view, "Refresh"); - entryNewAction = new EntryNewAction(view, "New entry"); - entryDeleteAction = new EntryDeleteAction(view, "Delete entry"); - - registerUpdateActions(); - } - - /** - * Registers a Listener on the Browser View and enable/disable the - * Actions according to the selection - */ - private void registerUpdateActions() { - // Handling selection of the Browser View to enable/disable the Actions - view.getSite().getPage().addSelectionListener(BrowserView.ID, - new ISelectionListener() { - public void selectionChanged(IWorkbenchPart part, - ISelection selection) { - Object selectedObject = ((TreeSelection) selection) - .getFirstElement(); - - if (selectedObject == null) { - connectionEditAction.setEnabled(false); - connectionDeleteAction.setEnabled(false); - entryNewAction.setEnabled(false); - entryDeleteAction.setEnabled(false); - } else { - if (selectedObject instanceof ConnectionWrapper) { - connectionEditAction.setEnabled(true); - connectionDeleteAction.setEnabled(true); - entryNewAction.setEnabled(false); - entryDeleteAction.setEnabled(false); - } else if (selectedObject instanceof EntryWrapper) { - connectionEditAction.setEnabled(false); - connectionDeleteAction.setEnabled(false); - entryNewAction.setEnabled(true); - entryDeleteAction.setEnabled(true); - } - } - } - }); - } - - /** - * Gets the ConnectionDeleteAction - * - * @return the ConnectionDeleteAction - */ - public IAction getConnectionDeleteAction() { - return connectionDeleteAction; - } - - /** - * Gets the ConnectionNewAction - * - * @return the ConnectionNewAction - */ - public IAction getConnectionNewAction() { - return connectionNewAction; - } - - /** - * Gets the ConnectionEditAction - * - * @return the ConnectionEditAction - */ - public IAction getConnectionEditAction() { - return connectionEditAction; - } - - /** - * Gets the RefreshAction - * - * @return the RefreshAction - */ - public IAction getRefreshAction() { - return refreshAction; - } - - /** - * Gets the EntryDeleteAction - * - * @return the EntryDeleteAction - */ - public IAction getEntryDeleteAction() { - return entryDeleteAction; - } - - /** - * Gets the EntryNewAction - * - * @return the EntryNewAction - */ - public IAction getEntryNewAction() { - return entryNewAction; + * (non-Javadoc) + * + * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) + */ + public void menuAboutToShow( IMenuManager manager ) + { + manager.add( connectionNewAction ); + manager.add( connectionEditAction ); + manager.add( connectionDeleteAction ); + manager.add( new Separator() ); + manager.add( refreshAction ); + manager.add( new Separator() ); + manager.add( entryNewAction ); + manager.add( entryDeleteAction ); + } + + + /** + * Sets the controlled View + * + * @param view + * the controlled View + */ + public void setView( final BrowserView view ) + { + this.view = view; + + // Adding DoubleClick behavior + view.getViewer().addDoubleClickListener( new IDoubleClickListener() + { + public void doubleClick( DoubleClickEvent event ) + { + // What we get from the treeViewer is a StructuredSelection + StructuredSelection selection = ( StructuredSelection ) event.getSelection(); + + // Here's the real object + Object objectSelection = selection.getFirstElement(); + + view.getViewer().setExpandedState( objectSelection, + !view.getViewer().getExpandedState( objectSelection ) ); + } + } ); + } + + + /** + * Creates all the actions + */ + public void createActions() + { + connectionNewAction = new ConnectionNewAction( view, "New connection" ); + connectionDeleteAction = new ConnectionDeleteAction( view, "Delete connection" ); + connectionEditAction = new ConnectionEditAction( view, "Edit connection" ); + refreshAction = new RefreshAction( view, "Refresh" ); + entryNewAction = new EntryNewAction( view, "New entry" ); + entryDeleteAction = new EntryDeleteAction( view, "Delete entry" ); + + registerUpdateActions(); + } + + + /** + * Registers a Listener on the Browser View and enable/disable the + * Actions according to the selection + */ + private void registerUpdateActions() + { + // Handling selection of the Browser View to enable/disable the Actions + view.getSite().getPage().addSelectionListener( BrowserView.ID, new ISelectionListener() + { + public void selectionChanged( IWorkbenchPart part, ISelection selection ) + { + Object selectedObject = ( ( TreeSelection ) selection ).getFirstElement(); + + if ( selectedObject == null ) + { + connectionEditAction.setEnabled( false ); + connectionDeleteAction.setEnabled( false ); + entryNewAction.setEnabled( false ); + entryDeleteAction.setEnabled( false ); + } + else + { + if ( selectedObject instanceof ConnectionWrapper ) + { + connectionEditAction.setEnabled( true ); + connectionDeleteAction.setEnabled( true ); + entryNewAction.setEnabled( false ); + entryDeleteAction.setEnabled( false ); + } + else if ( selectedObject instanceof EntryWrapper ) + { + connectionEditAction.setEnabled( false ); + connectionDeleteAction.setEnabled( false ); + entryNewAction.setEnabled( true ); + entryDeleteAction.setEnabled( true ); + } + } + } + } ); + } + + + /** + * Gets the ConnectionDeleteAction + * + * @return the ConnectionDeleteAction + */ + public IAction getConnectionDeleteAction() + { + return connectionDeleteAction; + } + + + /** + * Gets the ConnectionNewAction + * + * @return the ConnectionNewAction + */ + public IAction getConnectionNewAction() + { + return connectionNewAction; + } + + + /** + * Gets the ConnectionEditAction + * + * @return the ConnectionEditAction + */ + public IAction getConnectionEditAction() + { + return connectionEditAction; + } + + + /** + * Gets the RefreshAction + * + * @return the RefreshAction + */ + public IAction getRefreshAction() + { + return refreshAction; + } + + + /** + * Gets the EntryDeleteAction + * + * @return the EntryDeleteAction + */ + public IAction getEntryDeleteAction() + { + return entryDeleteAction; + } + + + /** + * Gets the EntryNewAction + * + * @return the EntryNewAction + */ + public IAction getEntryNewAction() + { + return entryNewAction; } } Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/PreferenceInitializer.java URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/PreferenceInitializer.java?view=diff&rev=488368&r1=488367&r2=488368 ============================================================================== --- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/PreferenceInitializer.java (original) +++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/PreferenceInitializer.java Mon Dec 18 09:52:58 2006 @@ -20,24 +20,27 @@ package org.apache.directory.ldapstudio.browser.controller; + import org.apache.directory.ldapstudio.browser.Activator; import org.apache.directory.ldapstudio.browser.view.views.ConnectionWizard; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.jface.preference.IPreferenceStore; + /** * This class initializes the preferences on the first start up of the plugin * * @author Apache Directory Project */ -public class PreferenceInitializer extends AbstractPreferenceInitializer { +public class PreferenceInitializer extends AbstractPreferenceInitializer +{ @Override - public void initializeDefaultPreferences() { - IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + public void initializeDefaultPreferences() + { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); - store.setDefault(ConnectionWizard.CONNECTIONS_PREFS, - ""); + store.setDefault( ConnectionWizard.CONNECTIONS_PREFS, "" ); } } Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeDeleteAction.java URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeDeleteAction.java?view=diff&rev=488368&r1=488367&r2=488368 ============================================================================== --- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeDeleteAction.java (original) +++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeDeleteAction.java Mon Dec 18 09:52:58 2006 @@ -20,6 +20,7 @@ package org.apache.directory.ldapstudio.browser.controller.actions; + import java.util.Iterator; import java.util.List; @@ -43,106 +44,110 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; + /** * This class implements the Attribute Delete Action. * * @author Apache Directory Project */ -public class AttributeDeleteAction extends Action { +public class AttributeDeleteAction extends Action +{ private AttributesView view; + /** - * Creates a new instance of AttributeDeleteAction. - * - * @param view - * the associated view - * @param text - * the associated text - */ - public AttributeDeleteAction(AttributesView view, String text) { - super(text); - setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin( - Activator.PLUGIN_ID, ImageKeys.ATTRIBUTE_DELETE)); - setToolTipText("Delete attribute"); - this.view = view; + * Creates a new instance of AttributeDeleteAction. + * + * @param view + * the associated view + * @param text + * the associated text + */ + public AttributeDeleteAction( AttributesView view, String text ) + { + super( text ); + setImageDescriptor( AbstractUIPlugin + .imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.ATTRIBUTE_DELETE ) ); + setToolTipText( "Delete attribute" ); + this.view = view; } + @SuppressWarnings("unchecked") - public void run() { - try { - // Getting the selected Entry in the Browser View - BrowserView browserView = (BrowserView) PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage().findView( - BrowserView.ID); - EntryWrapper entryWrapper = (EntryWrapper) ((TreeSelection) browserView - .getViewer().getSelection()).getFirstElement(); - SearchResultEntry entry = entryWrapper.getEntry(); - - // Initialization of the DSML Engine and the DSML Response - // Parser - Dsmlv2Engine engine = entryWrapper.getDsmlv2Engine(); - Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser(); - - // Getting the selected items - StructuredSelection selection = (StructuredSelection) view - .getViewer().getSelection(); - Iterator items = selection.iterator(); - - // Iterating on each attribute and generating a request to - // delete it. - String request = null; - while (items.hasNext()) { - List item = (List) items.next(); - String attributeName = item.get(0); - String attributeValue = item.get(1); - - request = "" + " " + " " - + " " + attributeValue + "" - + " " + " " - + ""; - - parser.setInput(engine.processDSML(request)); - parser.parse(); - - LdapResponse ldapResponse = parser.getBatchResponse() - .getCurrentResponse(); - - if (ldapResponse instanceof ModifyResponse) { - ModifyResponse modifyResponse = (ModifyResponse) ldapResponse; - - if (modifyResponse.getLdapResult().getResultCode() == 0) { - // Removing the selected attribute value - Attributes attributes = entry.getPartialAttributeList(); - attributes.get(attributeName).remove(attributeValue); - } else { - // Displaying an error - MessageDialog.openError(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(), - "Error !", "An error has ocurred.\n" - + modifyResponse.getLdapResult() - .getErrorMessage()); - } - } else if (ldapResponse instanceof ErrorResponse) { - ErrorResponse errorResponse = (ErrorResponse) ldapResponse; - - // Displaying an error - MessageDialog.openError(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(), "Error !", - "An error has ocurred.\n" - + errorResponse.getMessage()); - } - } - // refreshing the UI - view.setInput(entryWrapper); - view.resizeColumsToFit(); - } catch (Exception e) { - // Displaying an error - MessageDialog.openError(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(), "Error !", - "An error has ocurred.\n" + e.getMessage()); - } + public void run() + { + try + { + // Getting the selected Entry in the Browser View + BrowserView browserView = ( BrowserView ) PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getActivePage().findView( BrowserView.ID ); + EntryWrapper entryWrapper = ( EntryWrapper ) ( ( TreeSelection ) browserView.getViewer().getSelection() ) + .getFirstElement(); + SearchResultEntry entry = entryWrapper.getEntry(); + + // Initialization of the DSML Engine and the DSML Response + // Parser + Dsmlv2Engine engine = entryWrapper.getDsmlv2Engine(); + Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser(); + + // Getting the selected items + StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection(); + Iterator items = selection.iterator(); + + // Iterating on each attribute and generating a request to + // delete it. + String request = null; + while ( items.hasNext() ) + { + List item = ( List ) items.next(); + String attributeName = item.get( 0 ); + String attributeValue = item.get( 1 ); + + request = "" + " " + " " + " " + attributeValue + "" + + " " + " " + ""; + + parser.setInput( engine.processDSML( request ) ); + parser.parse(); + + LdapResponse ldapResponse = parser.getBatchResponse().getCurrentResponse(); + + if ( ldapResponse instanceof ModifyResponse ) + { + ModifyResponse modifyResponse = ( ModifyResponse ) ldapResponse; + + if ( modifyResponse.getLdapResult().getResultCode() == 0 ) + { + // Removing the selected attribute value + Attributes attributes = entry.getPartialAttributeList(); + attributes.get( attributeName ).remove( attributeValue ); + } + else + { + // Displaying an error + MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), + "Error !", "An error has ocurred.\n" + modifyResponse.getLdapResult().getErrorMessage() ); + } + } + else if ( ldapResponse instanceof ErrorResponse ) + { + ErrorResponse errorResponse = ( ErrorResponse ) ldapResponse; + + // Displaying an error + MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), + "Error !", "An error has ocurred.\n" + errorResponse.getMessage() ); + } + } + // refreshing the UI + view.setInput( entryWrapper ); + view.resizeColumsToFit(); + } + catch ( Exception e ) + { + // Displaying an error + MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error !", + "An error has ocurred.\n" + e.getMessage() ); + } } } Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeEditAction.java URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeEditAction.java?view=diff&rev=488368&r1=488367&r2=488368 ============================================================================== --- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeEditAction.java (original) +++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeEditAction.java Mon Dec 18 09:52:58 2006 @@ -20,42 +20,48 @@ package org.apache.directory.ldapstudio.browser.controller.actions; + import org.apache.directory.ldapstudio.browser.Activator; import org.apache.directory.ldapstudio.browser.view.ImageKeys; import org.apache.directory.ldapstudio.browser.view.views.AttributesView; import org.eclipse.jface.action.Action; import org.eclipse.ui.plugin.AbstractUIPlugin; + /** * This class implements the Attribute Edit Action. * * @author Apache Directory Project */ -public class AttributeEditAction extends Action { +public class AttributeEditAction extends Action +{ private AttributesView view; + /** - * Creates a new instance of AttributeEditAction. - * - * @param view - * the associated view - * @param text - * the string used as the text for the action - */ - public AttributeEditAction(AttributesView view, String text) { - super(text); - setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin( - Activator.PLUGIN_ID, ImageKeys.ATTRIBUTE_EDIT)); - setToolTipText("Edit attribute"); - this.view = view; + * Creates a new instance of AttributeEditAction. + * + * @param view + * the associated view + * @param text + * the string used as the text for the action + */ + public AttributeEditAction( AttributesView view, String text ) + { + super( text ); + setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.ATTRIBUTE_EDIT ) ); + setToolTipText( "Edit attribute" ); + this.view = view; } + /* - * (non-Javadoc) - * - * @see org.eclipse.jface.action.Action#run() - */ - public void run() { - new RenameAttributeAction(view, "Rename attribute").run(); + * (non-Javadoc) + * + * @see org.eclipse.jface.action.Action#run() + */ + public void run() + { + new RenameAttributeAction( view, "Rename attribute" ).run(); } } Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeNewAction.java URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeNewAction.java?view=diff&rev=488368&r1=488367&r2=488368 ============================================================================== --- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeNewAction.java (original) +++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeNewAction.java Mon Dec 18 09:52:58 2006 @@ -20,6 +20,7 @@ package org.apache.directory.ldapstudio.browser.controller.actions; + import org.apache.directory.ldapstudio.browser.Activator; import org.apache.directory.ldapstudio.browser.view.ImageKeys; import org.apache.directory.ldapstudio.browser.view.views.AttributeAddWizard; @@ -29,28 +30,32 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; + /** * This class implements the Attribute New Action. * * @author Apache Directory Project */ -public class AttributeNewAction extends Action { +public class AttributeNewAction extends Action +{ private AttributesView view; - public AttributeNewAction(AttributesView view, String text) { - super(text); - setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin( - Activator.PLUGIN_ID, ImageKeys.ATTRIBUTE_NEW)); - setToolTipText("New attribute"); - this.view = view; + + public AttributeNewAction( AttributesView view, String text ) + { + super( text ); + setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.ATTRIBUTE_NEW ) ); + setToolTipText( "New attribute" ); + this.view = view; } - public void run() { - // Creating the Wizard and opening it - AttributeAddWizard wizard = new AttributeAddWizard(); - WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(), wizard); - dialog.create(); - dialog.open(); + + public void run() + { + // Creating the Wizard and opening it + AttributeAddWizard wizard = new AttributeAddWizard(); + WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); + dialog.create(); + dialog.open(); } } Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionDeleteAction.java URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionDeleteAction.java?view=diff&rev=488368&r1=488367&r2=488368 ============================================================================== --- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionDeleteAction.java (original) +++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionDeleteAction.java Mon Dec 18 09:52:58 2006 @@ -20,6 +20,7 @@ package org.apache.directory.ldapstudio.browser.controller.actions; + import org.apache.directory.ldapstudio.browser.Activator; import org.apache.directory.ldapstudio.browser.model.Connection; import org.apache.directory.ldapstudio.browser.model.Connections; @@ -32,39 +33,44 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; + /** * This class implements the Connection Delete Action. * * @author Apache Directory Project */ -public class ConnectionDeleteAction extends Action { +public class ConnectionDeleteAction extends Action +{ private BrowserView view; - public ConnectionDeleteAction(BrowserView view, String text) { - super(text); - setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin( - Activator.PLUGIN_ID, ImageKeys.CONNECTION_DELETE)); - setToolTipText("Delete connection"); - this.view = view; + + public ConnectionDeleteAction( BrowserView view, String text ) + { + super( text ); + setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, + ImageKeys.CONNECTION_DELETE ) ); + setToolTipText( "Delete connection" ); + this.view = view; } - public void run() { - // Getting the selected connection - ConnectionWrapper connectionWrapper = (ConnectionWrapper) ((TreeSelection) view - .getViewer().getSelection()).getFirstElement(); - Connection selectedConnection = connectionWrapper.getConnection(); - - boolean answer = MessageDialog.openConfirm(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(), "Confirm", - "Are you sure you want to delete the connection \"" - + selectedConnection.getName() + "\"?"); - - if (!answer) { - // If the user clicks on the "Cancel" button, we return... - return; - } - // Removing the connection - Connections.getInstance().removeConnection(selectedConnection); + public void run() + { + // Getting the selected connection + ConnectionWrapper connectionWrapper = ( ConnectionWrapper ) ( ( TreeSelection ) view.getViewer().getSelection() ) + .getFirstElement(); + Connection selectedConnection = connectionWrapper.getConnection(); + + boolean answer = MessageDialog.openConfirm( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), + "Confirm", "Are you sure you want to delete the connection \"" + selectedConnection.getName() + "\"?" ); + + if ( !answer ) + { + // If the user clicks on the "Cancel" button, we return... + return; + } + + // Removing the connection + Connections.getInstance().removeConnection( selectedConnection ); } } Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionEditAction.java URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionEditAction.java?view=diff&rev=488368&r1=488367&r2=488368 ============================================================================== --- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionEditAction.java (original) +++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionEditAction.java Mon Dec 18 09:52:58 2006 @@ -20,6 +20,7 @@ package org.apache.directory.ldapstudio.browser.controller.actions; + import org.apache.directory.ldapstudio.browser.Activator; import org.apache.directory.ldapstudio.browser.model.Connection; import org.apache.directory.ldapstudio.browser.view.ImageKeys; @@ -35,52 +36,57 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; + /** * This class implements the Connection Edit Action * * @author Apache Directory Project */ -public class ConnectionEditAction extends Action { +public class ConnectionEditAction extends Action +{ private BrowserView view; - public ConnectionEditAction(BrowserView view, String text) { - super(text); - setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin( - Activator.PLUGIN_ID, ImageKeys.CONNECTION_EDIT)); - setToolTipText("Edit connection"); - this.view = view; + + public ConnectionEditAction( BrowserView view, String text ) + { + super( text ); + setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.CONNECTION_EDIT ) ); + setToolTipText( "Edit connection" ); + this.view = view; } - public void run() { - // Getting the selected connection - ConnectionWrapper connectionWrapper = (ConnectionWrapper) ((TreeSelection) view - .getViewer().getSelection()).getFirstElement(); - Connection selectedConnection = connectionWrapper.getConnection(); - - // Creating the Connection Wizard - ConnectionWizard wizard = new ConnectionWizard(); - wizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY); - wizard.setType(ConnectionWizardType.EDIT); - - wizard.setConnection(selectedConnection); - - // Instantiates the wizard container with the wizard and opens it - WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(), wizard); - dialog.create(); - int result = dialog.open(); - // O is returned when "Finish" is clicked, 1 is returned when "Cancel" + public void run() + { + // Getting the selected connection + ConnectionWrapper connectionWrapper = ( ConnectionWrapper ) ( ( TreeSelection ) view.getViewer().getSelection() ) + .getFirstElement(); + Connection selectedConnection = connectionWrapper.getConnection(); + + // Creating the Connection Wizard + ConnectionWizard wizard = new ConnectionWizard(); + wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY ); + wizard.setType( ConnectionWizardType.EDIT ); + + wizard.setConnection( selectedConnection ); + + // Instantiates the wizard container with the wizard and opens it + WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); + dialog.create(); + int result = dialog.open(); + + // O is returned when "Finish" is clicked, 1 is returned when "Cancel" // is clicked - if (result != 0) { - return; - } + if ( result != 0 ) + { + return; + } - // Updating the state of the Connection since it has changed (this + // Updating the state of the Connection since it has changed (this // causes the icon to change) - connectionWrapper.setState(ConnectionWrapperState.NONE); - connectionWrapper.connectionChanged(); + connectionWrapper.setState( ConnectionWrapperState.NONE ); + connectionWrapper.connectionChanged(); - selectedConnection.notifyListeners(); + selectedConnection.notifyListeners(); } } Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionNewAction.java URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionNewAction.java?view=diff&rev=488368&r1=488367&r2=488368 ============================================================================== --- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionNewAction.java (original) +++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionNewAction.java Mon Dec 18 09:52:58 2006 @@ -20,6 +20,7 @@ package org.apache.directory.ldapstudio.browser.controller.actions; + import org.apache.directory.ldapstudio.browser.Activator; import org.apache.directory.ldapstudio.browser.model.Connection; import org.apache.directory.ldapstudio.browser.model.Connections; @@ -33,60 +34,66 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; + /** * This class implements the Connection New Action * * @author Apache Directory Project */ -public class ConnectionNewAction extends Action { +public class ConnectionNewAction extends Action +{ private BrowserView view; - public ConnectionNewAction(BrowserView view, String text) { - super(text); - setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin( - Activator.PLUGIN_ID, ImageKeys.CONNECTION_NEW)); - setToolTipText("New connection"); - this.view = view; + + public ConnectionNewAction( BrowserView view, String text ) + { + super( text ); + setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.CONNECTION_NEW ) ); + setToolTipText( "New connection" ); + this.view = view; } - public void run() { - // Creating the new Connection - Connection newConnection = new Connection(); - - // Creating a new Connection Name with verification that a connection - // with - // the same name doesn't exist yet. - String newConnectionString = "New Connection"; - String testString = newConnectionString; - Connections connections = Connections.getInstance(); - - int counter = 1; - while (!connections.isConnectionNameAvailable(testString)) { - testString = newConnectionString + counter; - counter++; - } - newConnection.setName(testString); - - // Creating the Connection Wizard - ConnectionWizard wizard = new ConnectionWizard(); - wizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY); - wizard.setType(ConnectionWizardType.NEW); - - wizard.setConnection(newConnection); - - // Instantiates the wizard container with the wizard and opens it - WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(), wizard); - dialog.create(); - int result = dialog.open(); - - // O is returned when "Finish" is clicked, 1 is returned when "Cancel" - // is clicked - if (result != 0) { - return; - } - // Adding the connection - Connections.getInstance().addConnection(newConnection); + public void run() + { + // Creating the new Connection + Connection newConnection = new Connection(); + + // Creating a new Connection Name with verification that a connection + // with + // the same name doesn't exist yet. + String newConnectionString = "New Connection"; + String testString = newConnectionString; + Connections connections = Connections.getInstance(); + + int counter = 1; + while ( !connections.isConnectionNameAvailable( testString ) ) + { + testString = newConnectionString + counter; + counter++; + } + newConnection.setName( testString ); + + // Creating the Connection Wizard + ConnectionWizard wizard = new ConnectionWizard(); + wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY ); + wizard.setType( ConnectionWizardType.NEW ); + + wizard.setConnection( newConnection ); + + // Instantiates the wizard container with the wizard and opens it + WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard ); + dialog.create(); + int result = dialog.open(); + + // O is returned when "Finish" is clicked, 1 is returned when "Cancel" + // is clicked + if ( result != 0 ) + { + return; + } + + // Adding the connection + Connections.getInstance().addConnection( newConnection ); } } Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/EntryDeleteAction.java URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/EntryDeleteAction.java?view=diff&rev=488368&r1=488367&r2=488368 ============================================================================== --- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/EntryDeleteAction.java (original) +++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/EntryDeleteAction.java Mon Dec 18 09:52:58 2006 @@ -20,6 +20,7 @@ package org.apache.directory.ldapstudio.browser.controller.actions; + import java.util.Iterator; import java.util.List; @@ -40,128 +41,129 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; + /** * This class implements the Entry Delete Action * * @author Apache Directory Project */ -public class EntryDeleteAction extends Action { +public class EntryDeleteAction extends Action +{ private BrowserView view; - public EntryDeleteAction(BrowserView view, String text) { - super(text); - setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin( - Activator.PLUGIN_ID, ImageKeys.ENTRY_DELETE)); - setToolTipText("Delete entry"); - this.view = view; + + public EntryDeleteAction( BrowserView view, String text ) + { + super( text ); + setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.ENTRY_DELETE ) ); + setToolTipText( "Delete entry" ); + this.view = view; } - public void run() { - boolean answer = MessageDialog - .openConfirm(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(), "Confirm", - "Are you sure you want to delete the selected entry, including its children?"); - if (!answer) { - // If the user clicks on the "Cancel" button, we return... - return; - } - - try { - // Getting the selected items - StructuredSelection selection = (StructuredSelection) view - .getViewer().getSelection(); - Iterator items = selection.iterator(); - - while (items.hasNext()) { - EntryWrapper entryWrapper = (EntryWrapper) items.next(); - - // Initialization of the DSML Engine and the DSML Response - // Parser - Dsmlv2Engine engine = entryWrapper.getDsmlv2Engine(); - Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser(); - - String searchRequest = "" - + " " - + " " - + " " - + " " - + " " + " " - + ""; - - // Executing the request and sending the result to the Response - // Parser - parser.setInput(engine.processDSML(searchRequest)); - parser.parse(); - - LdapResponse ldapResponse = parser.getBatchResponse() - .getCurrentResponse(); - - if (ldapResponse instanceof ErrorResponse) { - ErrorResponse errorResponse = ((ErrorResponse) ldapResponse); - - // Displaying an error - MessageDialog.openError(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(), "Error !", - "An error has ocurred.\n" - + errorResponse.getMessage()); - return; - } else if (ldapResponse instanceof SearchResponse) { - - // Getting the Search Result Entry List containing our - // objects for the response - SearchResponse searchResponse = ((SearchResponse) ldapResponse); - List sreList = searchResponse - .getSearchResultEntryList(); - - String deleteRequest = ""; - for (int i = sreList.size() - 1; i >= 0; i--) { - deleteRequest += "\n"; - } - deleteRequest += ""; - - // Executing the request and sending the result to the - // Response Parser - parser.setInput(engine.processDSML(deleteRequest)); - parser.parse(); - - ldapResponse = parser.getBatchResponse() - .getCurrentResponse(); - - if (ldapResponse instanceof ErrorResponse) { - ErrorResponse errorResponse = ((ErrorResponse) ldapResponse); - - // Displaying an error - MessageDialog.openError(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(), - "Error !", "An error has ocurred.\n" - + errorResponse.getMessage()); - return; - } else if (ldapResponse instanceof DelResponse) { - DelResponse delResponse = (DelResponse) ldapResponse; - - if (delResponse.getLdapResult().getResultCode() == 0) { - view.getViewer().remove(entryWrapper); - } else { - // Displaying an error - MessageDialog.openError(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(), - "Error !", "An error has ocurred.\n" - + delResponse.getLdapResult() - .getErrorMessage()); - } - } - } - } - } catch (Exception e) { - // Displaying an error - MessageDialog.openError(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(), "Error !", - "An error has ocurred.\n" + e.getMessage()); - return; - } + + public void run() + { + boolean answer = MessageDialog.openConfirm( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), + "Confirm", "Are you sure you want to delete the selected entry, including its children?" ); + if ( !answer ) + { + // If the user clicks on the "Cancel" button, we return... + return; + } + + try + { + // Getting the selected items + StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection(); + Iterator items = selection.iterator(); + + while ( items.hasNext() ) + { + EntryWrapper entryWrapper = ( EntryWrapper ) items.next(); + + // Initialization of the DSML Engine and the DSML Response + // Parser + Dsmlv2Engine engine = entryWrapper.getDsmlv2Engine(); + Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser(); + + String searchRequest = "" + " " + + " " + " " + + " " + " " + " " + + ""; + + // Executing the request and sending the result to the Response + // Parser + parser.setInput( engine.processDSML( searchRequest ) ); + parser.parse(); + + LdapResponse ldapResponse = parser.getBatchResponse().getCurrentResponse(); + + if ( ldapResponse instanceof ErrorResponse ) + { + ErrorResponse errorResponse = ( ( ErrorResponse ) ldapResponse ); + + // Displaying an error + MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), + "Error !", "An error has ocurred.\n" + errorResponse.getMessage() ); + return; + } + else if ( ldapResponse instanceof SearchResponse ) + { + + // Getting the Search Result Entry List containing our + // objects for the response + SearchResponse searchResponse = ( ( SearchResponse ) ldapResponse ); + List sreList = searchResponse.getSearchResultEntryList(); + + String deleteRequest = ""; + for ( int i = sreList.size() - 1; i >= 0; i-- ) + { + deleteRequest += "\n"; + } + deleteRequest += ""; + + // Executing the request and sending the result to the + // Response Parser + parser.setInput( engine.processDSML( deleteRequest ) ); + parser.parse(); + + ldapResponse = parser.getBatchResponse().getCurrentResponse(); + + if ( ldapResponse instanceof ErrorResponse ) + { + ErrorResponse errorResponse = ( ( ErrorResponse ) ldapResponse ); + + // Displaying an error + MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), + "Error !", "An error has ocurred.\n" + errorResponse.getMessage() ); + return; + } + else if ( ldapResponse instanceof DelResponse ) + { + DelResponse delResponse = ( DelResponse ) ldapResponse; + + if ( delResponse.getLdapResult().getResultCode() == 0 ) + { + view.getViewer().remove( entryWrapper ); + } + else + { + // Displaying an error + MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), + "Error !", "An error has ocurred.\n" + delResponse.getLdapResult().getErrorMessage() ); + } + } + } + } + } + catch ( Exception e ) + { + // Displaying an error + MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error !", + "An error has ocurred.\n" + e.getMessage() ); + return; + } } } Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/EntryNewAction.java URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/EntryNewAction.java?view=diff&rev=488368&r1=488367&r2=488368 ============================================================================== --- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/EntryNewAction.java (original) +++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/EntryNewAction.java Mon Dec 18 09:52:58 2006 @@ -20,29 +20,35 @@ package org.apache.directory.ldapstudio.browser.controller.actions; + import org.apache.directory.ldapstudio.browser.Activator; import org.apache.directory.ldapstudio.browser.view.ImageKeys; import org.apache.directory.ldapstudio.browser.view.views.BrowserView; import org.eclipse.jface.action.Action; import org.eclipse.ui.plugin.AbstractUIPlugin; + /** * This class implements the Entry New Action * * @author Apache Directory Project */ -public class EntryNewAction extends Action { +public class EntryNewAction extends Action +{ private BrowserView view; - public EntryNewAction(BrowserView view, String text) { - super(text); - setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin( - Activator.PLUGIN_ID, ImageKeys.ENTRY_NEW)); - setToolTipText("New entry"); - this.view = view; + + public EntryNewAction( BrowserView view, String text ) + { + super( text ); + setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.ENTRY_NEW ) ); + setToolTipText( "New entry" ); + this.view = view; } - public void run() { - System.out.println("New entry"); + + public void run() + { + System.out.println( "New entry" ); } } Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RefreshAction.java URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RefreshAction.java?view=diff&rev=488368&r1=488367&r2=488368 ============================================================================== --- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RefreshAction.java (original) +++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RefreshAction.java Mon Dec 18 09:52:58 2006 @@ -20,6 +20,7 @@ package org.apache.directory.ldapstudio.browser.controller.actions; + import org.apache.directory.ldapstudio.browser.Activator; import org.apache.directory.ldapstudio.browser.view.ImageKeys; import org.apache.directory.ldapstudio.browser.view.views.AttributesView; @@ -32,49 +33,55 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; + /** * This class implements the Refresh Action * * @author Apache Directory Project */ -public class RefreshAction extends Action { +public class RefreshAction extends Action +{ private BrowserView view; - public RefreshAction(BrowserView view, String text) { - super(text); - setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin( - Activator.PLUGIN_ID, ImageKeys.REFRESH)); - setToolTipText("Refresh"); - this.view = view; - } - public void run() { - TreeViewer viewer = view.getViewer(); - - Object selection = ((TreeSelection) viewer.getSelection()) - .getFirstElement(); + public RefreshAction( BrowserView view, String text ) + { + super( text ); + setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.REFRESH ) ); + setToolTipText( "Refresh" ); + this.view = view; + } - boolean isExpanded = viewer.getExpandedState(selection); - // Clearing the children of the selected node - if (selection instanceof ConnectionWrapper) { - ConnectionWrapper connectionWrapper = (ConnectionWrapper) selection; - connectionWrapper.clearChildren(); - isExpanded = true; - } else if (selection instanceof EntryWrapper) { - EntryWrapper entryWrapper = (EntryWrapper) selection; - entryWrapper.clearChildren(); - entryWrapper.refreshAttributes(); - } - - // Refreshing the Browser View - viewer.refresh(selection); - viewer.setExpandedState(selection, isExpanded); - - // Refreshing the Attributes View - AttributesView attributesView = (AttributesView) PlatformUI - .getWorkbench().getActiveWorkbenchWindow().getActivePage() - .findView(AttributesView.ID); - attributesView.refresh(); + public void run() + { + TreeViewer viewer = view.getViewer(); + + Object selection = ( ( TreeSelection ) viewer.getSelection() ).getFirstElement(); + + boolean isExpanded = viewer.getExpandedState( selection ); + + // Clearing the children of the selected node + if ( selection instanceof ConnectionWrapper ) + { + ConnectionWrapper connectionWrapper = ( ConnectionWrapper ) selection; + connectionWrapper.clearChildren(); + isExpanded = true; + } + else if ( selection instanceof EntryWrapper ) + { + EntryWrapper entryWrapper = ( EntryWrapper ) selection; + entryWrapper.clearChildren(); + entryWrapper.refreshAttributes(); + } + + // Refreshing the Browser View + viewer.refresh( selection ); + viewer.setExpandedState( selection, isExpanded ); + + // Refreshing the Attributes View + AttributesView attributesView = ( AttributesView ) PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getActivePage().findView( AttributesView.ID ); + attributesView.refresh(); } } Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RenameAttributeAction.java URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RenameAttributeAction.java?view=diff&rev=488368&r1=488367&r2=488368 ============================================================================== --- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RenameAttributeAction.java (original) +++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RenameAttributeAction.java Mon Dec 18 09:52:58 2006 @@ -20,6 +20,7 @@ package org.apache.directory.ldapstudio.browser.controller.actions; + import org.apache.directory.ldapstudio.browser.view.views.AttributesView; import org.apache.directory.ldapstudio.browser.view.views.BrowserView; import org.apache.directory.ldapstudio.browser.view.views.wrappers.EntryWrapper; @@ -43,12 +44,14 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.PlatformUI; + /** * This class implements the Rename Attribute Action. * * @author Apache Directory Project */ -public class RenameAttributeAction extends Action { +public class RenameAttributeAction extends Action +{ private static final int COLUMN_TO_EDIT = 1; private AttributesView view; @@ -62,213 +65,228 @@ // A flag to not update twice the server private boolean done = false; + /** - * Creates a new instance of RenameAttributeAction. - * - * @param view - * the associated view - * @param text - * the string used as the text for the action - */ - public RenameAttributeAction(AttributesView view, String text) { - super(text); - this.view = view; - // this.table = view.getViewer().getTable(); + * Creates a new instance of RenameAttributeAction. + * + * @param view + * the associated view + * @param text + * the string used as the text for the action + */ + public RenameAttributeAction( AttributesView view, String text ) + { + super( text ); + this.view = view; + // this.table = view.getViewer().getTable(); } + /* - * (non-Javadoc) - * - * @see org.eclipse.jface.action.Action#run() - */ - public void run() { - createEditor(); - showEditor(); - } - - /** - * Creates the Editor cell and registers associated listeners - */ - private void createEditor() { - // // Creating the Table Editor - // tableEditor = new TableEditor( table ); - // tableEditor.horizontalAlignment = SWT.LEFT; - // tableEditor.grabHorizontal = true; - // tableEditor.minimumWidth = 50; - // - // // Creating the Text Widget that will be used by the user - // // to enter the new value - // textEditor = new Text( view.getViewer().getTable(), SWT.NONE ); - // - // // Adding Traverse Listener used to handle event when the 'return' - // // or 'escape' key is pressed - // textEditor.addListener( SWT.Traverse, new Listener() - // { - // public void handleEvent( Event event ) - // { - // // Workaround for bug 20214 due to extra traverse events - // switch ( event.detail ) - // { - // case SWT.TRAVERSE_ESCAPE: // Escape Key - // // Do nothing in this case - // disposeEditor(); - // event.doit = true; - // event.detail = SWT.TRAVERSE_NONE; - // break; - // case SWT.TRAVERSE_RETURN: // Return Key - // saveChangesAndDisposeEditor(); - // event.doit = true; - // event.detail = SWT.TRAVERSE_NONE; - // break; - // } - // } - // } ); - // - // // Adding Focus Listener used to handle event when the user - // // clicks on the elsewhere - // textEditor.addFocusListener( new FocusAdapter() - // { - // public void focusLost( FocusEvent fe ) - // { - // if ( !done ) - // { - // saveChangesAndDisposeEditor(); - // } - // } - // } ); - } - - /** - * Shows the editor - */ - private void showEditor() { - // tableEditor.setEditor( textEditor, - // view.getViewer().getTable().getSelection()[0], COLUMN_TO_EDIT ); - textEditor.setText(getAttributeValue()); - textEditor.selectAll(); - textEditor.setFocus(); - } - - /** - * Saves the changes made in the editor and disposes the editor - */ - private void saveChangesAndDisposeEditor() { - if (!getAttributeValue().equals(textEditor.getText())) { - saveChanges(); - } - disposeEditor(); - } - - /** - * Disposes the editor and refreshes the Atttributes View UI - */ - private void disposeEditor() { - textEditor.dispose(); - textEditor = null; - tableEditor.setEditor(null, null, COLUMN_TO_EDIT); - - // Resizing Columns and resetting the focus on the Table - view.resizeColumsToFit(); - // view.getViewer().getTable().setFocus(); - } - - /** - * Gets the name of the selected attribute - * - * @return the name of the selected attribute - */ - private String getAttributeName() { - // TableItem item = view.getSelectedAttributeTableItem(); - // return item.getText( 0 ); - return ""; - } - - /** - * Gets the value of the selected attribute - * - * @return the value of the selected attribute - */ - private String getAttributeValue() { - // TableItem item = view.getSelectedAttributeTableItem(); - // return item.getText( 1 ); - return ""; - } - - /** - * Saves the changes made in the editor on the server - * - * @param newText - */ - private void saveChanges() { - try { - // Getting the Browser View - BrowserView browserView = (BrowserView) PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage().findView( - BrowserView.ID); - - EntryWrapper entryWrapper = (EntryWrapper) ((TreeSelection) browserView - .getViewer().getSelection()).getFirstElement(); - SearchResultEntry entry = entryWrapper.getEntry(); - - // Initialization of the DSML Engine and the DSML Response - // Parser - Dsmlv2Engine engine = entryWrapper.getDsmlv2Engine(); - Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser(); - - String request = "" + " " - + " " + " " - + getAttributeValue() + "" - + " " + " " - + " " + textEditor.getText() + "" - + " " + " " - + ""; - - parser.setInput(engine.processDSML(request)); - parser.parse(); - - LdapResponse ldapResponse = parser.getBatchResponse() - .getCurrentResponse(); - - if (ldapResponse instanceof ModifyResponse) { - ModifyResponse modifyResponse = (ModifyResponse) ldapResponse; - - if (modifyResponse.getLdapResult().getResultCode() == 0) { - entry.getPartialAttributeList().get(getAttributeName()) - .remove(getAttributeValue()); - entry.getPartialAttributeList().get(getAttributeName()) - .add(textEditor.getText()); - - // TableItem item = - // view.getSelectedAttributeTableItem(); - // item.setText( 1, textEditor.getText() ); - // view.getViewer().refresh( item ); - } else { - done = true; - // Displaying an error - MessageDialog.openError(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(), "Error !", - "An error has ocurred.\n" - + modifyResponse.getLdapResult() - .getErrorMessage()); - } - } else if (ldapResponse instanceof ErrorResponse) { - ErrorResponse errorResponse = (ErrorResponse) ldapResponse; - - done = true; - // Displaying an error - MessageDialog.openError(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(), "Error !", - "An error has ocurred.\n" + errorResponse.getMessage()); - } - } catch (Exception e) { - done = true; - // Displaying an error - MessageDialog.openError(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(), "Error !", - "An error has ocurred.\n" + e.getMessage()); - } + * (non-Javadoc) + * + * @see org.eclipse.jface.action.Action#run() + */ + public void run() + { + createEditor(); + showEditor(); + } + + + /** + * Creates the Editor cell and registers associated listeners + */ + private void createEditor() + { + // // Creating the Table Editor + // tableEditor = new TableEditor( table ); + // tableEditor.horizontalAlignment = SWT.LEFT; + // tableEditor.grabHorizontal = true; + // tableEditor.minimumWidth = 50; + // + // // Creating the Text Widget that will be used by the user + // // to enter the new value + // textEditor = new Text( view.getViewer().getTable(), SWT.NONE ); + // + // // Adding Traverse Listener used to handle event when the 'return' + // // or 'escape' key is pressed + // textEditor.addListener( SWT.Traverse, new Listener() + // { + // public void handleEvent( Event event ) + // { + // // Workaround for bug 20214 due to extra traverse events + // switch ( event.detail ) + // { + // case SWT.TRAVERSE_ESCAPE: // Escape Key + // // Do nothing in this case + // disposeEditor(); + // event.doit = true; + // event.detail = SWT.TRAVERSE_NONE; + // break; + // case SWT.TRAVERSE_RETURN: // Return Key + // saveChangesAndDisposeEditor(); + // event.doit = true; + // event.detail = SWT.TRAVERSE_NONE; + // break; + // } + // } + // } ); + // + // // Adding Focus Listener used to handle event when the user + // // clicks on the elsewhere + // textEditor.addFocusListener( new FocusAdapter() + // { + // public void focusLost( FocusEvent fe ) + // { + // if ( !done ) + // { + // saveChangesAndDisposeEditor(); + // } + // } + // } ); + } + + + /** + * Shows the editor + */ + private void showEditor() + { + // tableEditor.setEditor( textEditor, + // view.getViewer().getTable().getSelection()[0], COLUMN_TO_EDIT ); + textEditor.setText( getAttributeValue() ); + textEditor.selectAll(); + textEditor.setFocus(); + } + + + /** + * Saves the changes made in the editor and disposes the editor + */ + private void saveChangesAndDisposeEditor() + { + if ( !getAttributeValue().equals( textEditor.getText() ) ) + { + saveChanges(); + } + disposeEditor(); + } + + + /** + * Disposes the editor and refreshes the Atttributes View UI + */ + private void disposeEditor() + { + textEditor.dispose(); + textEditor = null; + tableEditor.setEditor( null, null, COLUMN_TO_EDIT ); + + // Resizing Columns and resetting the focus on the Table + view.resizeColumsToFit(); + // view.getViewer().getTable().setFocus(); + } + + + /** + * Gets the name of the selected attribute + * + * @return the name of the selected attribute + */ + private String getAttributeName() + { + // TableItem item = view.getSelectedAttributeTableItem(); + // return item.getText( 0 ); + return ""; + } + + + /** + * Gets the value of the selected attribute + * + * @return the value of the selected attribute + */ + private String getAttributeValue() + { + // TableItem item = view.getSelectedAttributeTableItem(); + // return item.getText( 1 ); + return ""; + } + + + /** + * Saves the changes made in the editor on the server + * + * @param newText + */ + private void saveChanges() + { + try + { + // Getting the Browser View + BrowserView browserView = ( BrowserView ) PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getActivePage().findView( BrowserView.ID ); + + EntryWrapper entryWrapper = ( EntryWrapper ) ( ( TreeSelection ) browserView.getViewer().getSelection() ) + .getFirstElement(); + SearchResultEntry entry = entryWrapper.getEntry(); + + // Initialization of the DSML Engine and the DSML Response + // Parser + Dsmlv2Engine engine = entryWrapper.getDsmlv2Engine(); + Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser(); + + String request = "" + " " + " " + " " + getAttributeValue() + + "" + " " + " " + " " + textEditor.getText() + "" + + " " + " " + ""; + + parser.setInput( engine.processDSML( request ) ); + parser.parse(); + + LdapResponse ldapResponse = parser.getBatchResponse().getCurrentResponse(); + + if ( ldapResponse instanceof ModifyResponse ) + { + ModifyResponse modifyResponse = ( ModifyResponse ) ldapResponse; + + if ( modifyResponse.getLdapResult().getResultCode() == 0 ) + { + entry.getPartialAttributeList().get( getAttributeName() ).remove( getAttributeValue() ); + entry.getPartialAttributeList().get( getAttributeName() ).add( textEditor.getText() ); + + // TableItem item = + // view.getSelectedAttributeTableItem(); + // item.setText( 1, textEditor.getText() ); + // view.getViewer().refresh( item ); + } + else + { + done = true; + // Displaying an error + MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), + "Error !", "An error has ocurred.\n" + modifyResponse.getLdapResult().getErrorMessage() ); + } + } + else if ( ldapResponse instanceof ErrorResponse ) + { + ErrorResponse errorResponse = ( ErrorResponse ) ldapResponse; + + done = true; + // Displaying an error + MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error !", + "An error has ocurred.\n" + errorResponse.getMessage() ); + } + } + catch ( Exception e ) + { + done = true; + // Displaying an error + MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error !", + "An error has ocurred.\n" + e.getMessage() ); + } } }