You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2006/12/18 18:57:49 UTC
svn commit: r488371 [13/14] - in /directory/sandbox/pamarcelot/ldapstudio:
ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/jobs/
ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/perspective/
ldapstudio-browser-u...
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewLdifFileWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewLdifFileWizard.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewLdifFileWizard.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewLdifFileWizard.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.ui.editors.ldif.LdifEditor;
+import org.apache.directory.ldapstudio.browser.ui.editors.ldif.NonExistingLdifEditorInput;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+
+
+public class NewLdifFileWizard extends Wizard implements INewWizard
+{
+
+ private IWorkbenchWindow window;
+
+
+ public NewLdifFileWizard()
+ {
+ }
+
+
+ public void init( IWorkbench workbench, IStructuredSelection selection )
+ {
+ window = workbench.getActiveWorkbenchWindow();
+ }
+
+
+ public void dispose()
+ {
+ window = null;
+ }
+
+
+ public static String getId()
+ {
+ return NewLdifFileWizard.class.getName();
+ }
+
+
+ public boolean performFinish()
+ {
+
+ IEditorInput input = new NonExistingLdifEditorInput();
+ String editorId = LdifEditor.getId();
+
+ try
+ {
+ IWorkbenchPage page = window.getActivePage();
+ page.openEditor( input, editorId );
+ }
+ catch ( PartInitException e )
+ {
+ return false;
+ }
+ return true;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewSearchWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewSearchWizard.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewSearchWizard.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewSearchWizard.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.ui.search.SearchPage;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.search.ui.NewSearchUI;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+
+
+public class NewSearchWizard extends Wizard implements INewWizard
+{
+
+ private IWorkbenchWindow window;
+
+
+ public NewSearchWizard()
+ {
+ }
+
+
+ public void init( IWorkbench workbench, IStructuredSelection selection )
+ {
+ window = workbench.getActiveWorkbenchWindow();
+ }
+
+
+ public void dispose()
+ {
+ window = null;
+ }
+
+
+ public static String getId()
+ {
+ return NewSearchWizard.class.getName();
+ }
+
+
+ public boolean performFinish()
+ {
+ NewSearchUI.openSearchDialog( window, SearchPage.getId() );
+ return true;
+ }
+
+}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connections.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connections.java?view=diff&rev=488371&r1=488370&r2=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connections.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connections.java Mon Dec 18 09:57:38 2006
@@ -20,6 +20,7 @@
package org.apache.directory.ldapstudio.browser.model;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -31,262 +32,302 @@
import org.eclipse.ui.PlatformUI;
import org.xmlpull.v1.XmlPullParserException;
+
/**
* This class represent the Connections class used to store all the connections
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class Connections implements ConnectionListener {
+public class Connections implements ConnectionListener
+{
/**
- * The Preferences identifier for storing the Connections
- */
+ * The Preferences identifier for storing the Connections
+ */
private static final String CONNECTIONS_PREFS = "connections_prefs";
/**
- * The Connections List
- */
+ * The Connections List
+ */
private List<Connection> connections;
/**
- * The Listeners List
- */
+ * The Listeners List
+ */
private List<ConnectionsListener> listeners;
/**
- * The instance (used to access Connections as a Singleton)
- */
+ * The instance (used to access Connections as a Singleton)
+ */
private static Connections instance;
// Static thread-safe singleton initializer
- static {
- instance = new Connections();
+ static
+ {
+ instance = new Connections();
}
+
/**
- * Private constructor
- */
- private Connections() {
- connections = new ArrayList<Connection>();
- listeners = new ArrayList<ConnectionsListener>();
+ * Private constructor
+ */
+ private Connections()
+ {
+ connections = new ArrayList<Connection>();
+ listeners = new ArrayList<ConnectionsListener>();
- loadConnections();
+ loadConnections();
}
+
/**
- * Loads the Connections
- */
- private void loadConnections() {
- Preferences store = Activator.getDefault().getPluginPreferences();
+ * Loads the Connections
+ */
+ private void loadConnections()
+ {
+ Preferences store = Activator.getDefault().getPluginPreferences();
- String connectionsAsXml = store.getString(CONNECTIONS_PREFS);
+ String connectionsAsXml = store.getString( CONNECTIONS_PREFS );
- try {
- ConnectionParser parser = new ConnectionParser();
+ try
+ {
+ ConnectionParser parser = new ConnectionParser();
- parser.parse(connectionsAsXml);
+ parser.parse( connectionsAsXml );
- connections = parser.getConnections();
+ connections = parser.getConnections();
- // Registering this class as a listener for modification on any
- // Connection.
- for (Connection connection : connections) {
- connection.addListener(this);
- }
- } catch (XmlPullParserException e) {
- MessageDialog.openError(PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell(), "Error",
- "An error ocurred while recovering the connections.");
- }
+ // Registering this class as a listener for modification on any
+ // Connection.
+ for ( Connection connection : connections )
+ {
+ connection.addListener( this );
+ }
+ }
+ catch ( XmlPullParserException e )
+ {
+ MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error",
+ "An error ocurred while recovering the connections." );
+ }
}
+
/**
- * Stores the Connections
- */
- private void storeConnections() {
- Preferences store = Activator.getDefault().getPluginPreferences();
+ * Stores the Connections
+ */
+ private void storeConnections()
+ {
+ Preferences store = Activator.getDefault().getPluginPreferences();
- StringBuffer sb = new StringBuffer();
+ StringBuffer sb = new StringBuffer();
- // Constructing the XML String representing all the Connections
- sb.append("<connections>");
- for (int i = 0; i < connections.size(); i++) {
- sb.append(connections.get(i).toXml());
- }
- sb.append("</connections>");
+ // Constructing the XML String representing all the Connections
+ sb.append( "<connections>" );
+ for ( int i = 0; i < connections.size(); i++ )
+ {
+ sb.append( connections.get( i ).toXml() );
+ }
+ sb.append( "</connections>" );
- store.setValue(CONNECTIONS_PREFS, sb.toString());
+ store.setValue( CONNECTIONS_PREFS, sb.toString() );
}
+
/**
- * Use this method to get the singleton instance of the controller
- *
- * @return
- */
- public static Connections getInstance() {
- return instance;
+ * Use this method to get the singleton instance of the controller
+ *
+ * @return
+ */
+ public static Connections getInstance()
+ {
+ return instance;
}
+
/**
- * Adds a Connection
- *
- * @param connection
- * the Connection to add
- * @return true (as per the general contract of Collection.add).
- */
- public boolean addConnection(Connection connection) {
- if (connection != null) {
- boolean bool = connections.add(connection);
+ * Adds a Connection
+ *
+ * @param connection
+ * the Connection to add
+ * @return true (as per the general contract of Collection.add).
+ */
+ public boolean addConnection( Connection connection )
+ {
+ if ( connection != null )
+ {
+ boolean bool = connections.add( connection );
- connection.addListener(this);
+ connection.addListener( this );
- // Notifying the listeners
- notifyChanged(new ConnectionsEvent(ConnectionsEventType.ADD,
- connection));
+ // Notifying the listeners
+ notifyChanged( new ConnectionsEvent( ConnectionsEventType.ADD, connection ) );
- // Saving the Connections
- storeConnections();
+ // Saving the Connections
+ storeConnections();
- return bool;
- }
- return false;
+ return bool;
+ }
+ return false;
}
+
/**
- * Removes a Connection
- *
- * @param connection
- * the Connection to remove
- * @return true if the list contained the specified element.
- */
- public boolean removeConnection(Connection connection) {
- if (connection != null) {
- boolean bool = connections.remove(connection);
+ * Removes a Connection
+ *
+ * @param connection
+ * the Connection to remove
+ * @return true if the list contained the specified element.
+ */
+ public boolean removeConnection( Connection connection )
+ {
+ if ( connection != null )
+ {
+ boolean bool = connections.remove( connection );
- connection.removeListener(this);
+ connection.removeListener( this );
- // Notifying the listeners
- notifyChanged(new ConnectionsEvent(ConnectionsEventType.REMOVE,
- connection));
+ // Notifying the listeners
+ notifyChanged( new ConnectionsEvent( ConnectionsEventType.REMOVE, connection ) );
- // Saving the Connections
- storeConnections();
+ // Saving the Connections
+ storeConnections();
- return bool;
- }
- return false;
+ return bool;
+ }
+ return false;
}
+
/**
- * Notifies all the listeners that the Connections have changed
- *
- * @param event
- * the associated event
- */
- private void notifyChanged(ConnectionsEvent event) {
- for (ConnectionsListener listener : listeners) {
- listener.connectionsChanged(this, event);
- }
+ * Notifies all the listeners that the Connections have changed
+ *
+ * @param event
+ * the associated event
+ */
+ private void notifyChanged( ConnectionsEvent event )
+ {
+ for ( ConnectionsListener listener : listeners )
+ {
+ listener.connectionsChanged( this, event );
+ }
}
+
/**
- * Return the Connection at the specified position in the list
- *
- * @param index
- * index of element to return
- * @return the element at the specified position in this list
- * @throws IndexOutOfBoundsException
- * if the index is out of range (index < 0 || index >=
- * size())
- */
- public Connection getConnection(int index) throws IndexOutOfBoundsException {
- return connections.get(index);
+ * Return the Connection at the specified position in the list
+ *
+ * @param index
+ * index of element to return
+ * @return the element at the specified position in this list
+ * @throws IndexOutOfBoundsException
+ * if the index is out of range (index < 0 || index >=
+ * size())
+ */
+ public Connection getConnection( int index ) throws IndexOutOfBoundsException
+ {
+ return connections.get( index );
}
+
/**
- * Returns the number of elements in this list. If this list contains
- * more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE
- *
- * @return the number of elements in this list
- */
- public int size() {
- return connections.size();
+ * Returns the number of elements in this list. If this list contains
+ * more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE
+ *
+ * @return the number of elements in this list
+ */
+ public int size()
+ {
+ return connections.size();
}
+
/**
- * Adds a listener for the Connections modifications
- *
- * @param listener
- * the listener to add
- * @return true (as per the general contract of Collection.add).
- */
- public boolean addListener(ConnectionsListener listener) {
- return listeners.add(listener);
+ * Adds a listener for the Connections modifications
+ *
+ * @param listener
+ * the listener to add
+ * @return true (as per the general contract of Collection.add).
+ */
+ public boolean addListener( ConnectionsListener listener )
+ {
+ return listeners.add( listener );
}
+
/**
- * Removes a listener for the Connections modifications
- *
- * @param listener
- * the listener to remove
- * @return true if the list contained the specified element.
- */
- public boolean removeListener(ConnectionsListener listener) {
- return listeners.remove(listener);
+ * Removes a listener for the Connections modifications
+ *
+ * @param listener
+ * the listener to remove
+ * @return true if the list contained the specified element.
+ */
+ public boolean removeListener( ConnectionsListener listener )
+ {
+ return listeners.remove( listener );
}
+
/**
- * Sorts the connections into ascending order, according to the natural
- * ordering.
- */
- public void sort() {
- Collections.sort(connections);
+ * Sorts the connections into ascending order, according to the natural
+ * ordering.
+ */
+ public void sort()
+ {
+ Collections.sort( connections );
}
+
/**
- * Verifies if the name is already used by a connection
- *
- * @param name
- * the name
- * @param excludeName
- * a name to exclude from the verification
- * @return true if the name is available, false if a connection already
- * has a same name
- */
- public boolean isConnectionNameAvailable(String name, String excludeName) {
- for (int i = 0; i < size(); i++) {
- if (name.equals(getConnection(i).getName())) {
- if (!name.equals(excludeName)) {
- return false;
- }
- }
- }
- return true;
+ * Verifies if the name is already used by a connection
+ *
+ * @param name
+ * the name
+ * @param excludeName
+ * a name to exclude from the verification
+ * @return true if the name is available, false if a connection already
+ * has a same name
+ */
+ public boolean isConnectionNameAvailable( String name, String excludeName )
+ {
+ for ( int i = 0; i < size(); i++ )
+ {
+ if ( name.equals( getConnection( i ).getName() ) )
+ {
+ if ( !name.equals( excludeName ) )
+ {
+ return false;
+ }
+ }
+ }
+ return true;
}
+
/**
- * Verifies if the name is already used by a connection
- *
- * @param name
- * the name
- * @return true if the name is available, false if a connection already
- * has a same name
- */
- public boolean isConnectionNameAvailable(String name) {
- return isConnectionNameAvailable(name, null);
+ * Verifies if the name is already used by a connection
+ *
+ * @param name
+ * the name
+ * @return true if the name is available, false if a connection already
+ * has a same name
+ */
+ public boolean isConnectionNameAvailable( String name )
+ {
+ return isConnectionNameAvailable( name, null );
}
+
/**
- * This method is called if the Connection have been modified
- *
- * @param connection
- * the Connection
- */
- public void connectionChanged(Connection connection) {
- // Notifying the listeners
- notifyChanged(new ConnectionsEvent(ConnectionsEventType.UPDATE,
- connection));
+ * This method is called if the Connection have been modified
+ *
+ * @param connection
+ * the Connection
+ */
+ public void connectionChanged( Connection connection )
+ {
+ // Notifying the listeners
+ notifyChanged( new ConnectionsEvent( ConnectionsEventType.UPDATE, connection ) );
- // Saving the Connections
- storeConnections();
+ // Saving the Connections
+ storeConnections();
}
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionsEvent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionsEvent.java?view=diff&rev=488371&r1=488370&r2=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionsEvent.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionsEvent.java Mon Dec 18 09:57:38 2006
@@ -20,6 +20,7 @@
package org.apache.directory.ldapstudio.browser.model;
+
/**
* This class is used to represent the events related to modifications on the
* Connections Class, such as : - "Add", - "Update" or - "Remove" of a
@@ -27,36 +28,44 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class ConnectionsEvent {
+public class ConnectionsEvent
+{
/**
- * This enum represents the different types of a ConnectionEvent
- */
- public enum ConnectionsEventType {
- ADD, UPDATE, REMOVE
+ * This enum represents the different types of a ConnectionEvent
+ */
+ public enum ConnectionsEventType
+ {
+ ADD, UPDATE, REMOVE
};
private ConnectionsEventType type;
private Connection connection;
+
/**
- * Default constructor
- *
- * @param type
- * the type of the event
- * @param connection
- * the connection associated with the event
- */
- public ConnectionsEvent(ConnectionsEventType type, Connection connection) {
- this.type = type;
- this.connection = connection;
+ * Default constructor
+ *
+ * @param type
+ * the type of the event
+ * @param connection
+ * the connection associated with the event
+ */
+ public ConnectionsEvent( ConnectionsEventType type, Connection connection )
+ {
+ this.type = type;
+ this.connection = connection;
}
- public Connection getConnection() {
- return connection;
+
+ public Connection getConnection()
+ {
+ return connection;
}
- public ConnectionsEventType getType() {
- return type;
+
+ public ConnectionsEventType getType()
+ {
+ return type;
}
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionsListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionsListener.java?view=diff&rev=488371&r1=488370&r2=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionsListener.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionsListener.java Mon Dec 18 09:57:38 2006
@@ -20,21 +20,22 @@
package org.apache.directory.ldapstudio.browser.model;
+
/**
* Interface that has to be implemented by each Class that wants to listen on
* changes on Connections
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public interface ConnectionsListener {
+public interface ConnectionsListener
+{
/**
- * This method is called if the Connections have changed
- *
- * @param connections
- * the Connections
- * @param event
- * the event associated
- */
- public void connectionsChanged(Connections connections,
- ConnectionsEvent event);
+ * This method is called if the Connections have changed
+ *
+ * @param connections
+ * the Connections
+ * @param event
+ * the event associated
+ */
+ public void connectionsChanged( Connections connections, ConnectionsEvent event );
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/GrammarAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/GrammarAction.java?view=diff&rev=488371&r1=488370&r2=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/GrammarAction.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/GrammarAction.java Mon Dec 18 09:57:38 2006
@@ -20,41 +20,47 @@
package org.apache.directory.ldapstudio.browser.model;
+
/**
* A top level grammar class that store meta informations about the actions.
* Those informations are not mandatory, but they can be usefull for debugging.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public abstract class GrammarAction implements IAction {
+public abstract class GrammarAction implements IAction
+{
// ~ Instance fields
// ----------------------------------------------------------------------------
/** The action's name */
protected String name;
+
// ~ Constructors
// -------------------------------------------------------------------------------
/**
- * Creates a new GrammarAction object.
- *
- * @param name
- * The name of the create daction
- */
- public GrammarAction(String name) {
- this.name = name;
+ * Creates a new GrammarAction object.
+ *
+ * @param name
+ * The name of the create daction
+ */
+ public GrammarAction( String name )
+ {
+ this.name = name;
}
+
// ~ Methods
// ------------------------------------------------------------------------------------
/**
- * Print the action's name
- *
- * @return The action's name
- */
- public String toString() {
- return name;
+ * Print the action's name
+ *
+ * @return The action's name
+ */
+ public String toString()
+ {
+ return name;
}
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/GrammarTransition.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/GrammarTransition.java?view=diff&rev=488371&r1=488370&r2=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/GrammarTransition.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/GrammarTransition.java Mon Dec 18 09:57:38 2006
@@ -20,13 +20,15 @@
package org.apache.directory.ldapstudio.browser.model;
+
/**
* Define a transition between two states of a grammar. It stores the next
* state, and the action to execute while transiting.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class GrammarTransition {
+public class GrammarTransition
+{
// ~ Instance fields
// ----------------------------------------------------------------------------
@@ -39,50 +41,57 @@
/** The current state */
private int currentState;
+
// ~ Constructors
// -------------------------------------------------------------------------------
/**
- * Creates a new GrammarTransition object.
- *
- * @param currentState
- * The current transition
- * @param nextState
- * The target state
- * @param action
- * The action to execute. It could be null.
- */
- public GrammarTransition(int currentState, int nextState,
- GrammarAction action) {
- this.currentState = currentState;
- this.nextState = nextState;
- this.action = action;
+ * Creates a new GrammarTransition object.
+ *
+ * @param currentState
+ * The current transition
+ * @param nextState
+ * The target state
+ * @param action
+ * The action to execute. It could be null.
+ */
+ public GrammarTransition( int currentState, int nextState, GrammarAction action )
+ {
+ this.currentState = currentState;
+ this.nextState = nextState;
+ this.action = action;
}
+
// ~ Methods
// ------------------------------------------------------------------------------------
/**
- * @return Returns the target state.
- */
- public int getNextState() {
- return nextState;
+ * @return Returns the target state.
+ */
+ public int getNextState()
+ {
+ return nextState;
}
+
/**
- * Tells if the transition has an associated action.
- *
- * @return <code>true</code> if an action has been asociated to the
- * transition
- */
- public boolean hasAction() {
- return action != null;
+ * Tells if the transition has an associated action.
+ *
+ * @return <code>true</code> if an action has been asociated to the
+ * transition
+ */
+ public boolean hasAction()
+ {
+ return action != null;
}
+
/**
- * @return Returns the action associated with the transition
- */
- public GrammarAction getAction() {
- return action;
+ * @return Returns the action associated with the transition
+ */
+ public GrammarAction getAction()
+ {
+ return action;
}
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/IAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/IAction.java?view=diff&rev=488371&r1=488370&r2=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/IAction.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/IAction.java Mon Dec 18 09:57:38 2006
@@ -20,26 +20,28 @@
package org.apache.directory.ldapstudio.browser.model;
+
import org.xmlpull.v1.XmlPullParserException;
+
/**
* IAction interface just contains the method 'action' which must be implemented
* in all the implementong classes.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public interface IAction {
+public interface IAction
+{
// ~ Methods
// ------------------------------------------------------------------------------------
/**
- * The action to be executed.
- *
- * @param container
- * The container which stores the current data
- * @throws DecoderException
- * Thrown if something went wrong.
- */
- public void action(ConnectionParserContainer container)
- throws XmlPullParserException;
+ * The action to be executed.
+ *
+ * @param container
+ * The container which stores the current data
+ * @throws DecoderException
+ * Thrown if something went wrong.
+ */
+ public void action( ConnectionParserContainer container ) throws XmlPullParserException;
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/IGrammar.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/IGrammar.java?view=diff&rev=488371&r1=488370&r2=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/IGrammar.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/IGrammar.java Mon Dec 18 09:57:38 2006
@@ -20,38 +20,41 @@
package org.apache.directory.ldapstudio.browser.model;
+
/**
* The interface which expose common behavior of a Gramar implementer.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public interface IGrammar {
+public interface IGrammar
+{
// ~ Methods
// ------------------------------------------------------------------------------------
/**
- * This method, when called, execute an action on the current data
- * stored in the container.
- *
- * @param asn1Container
- * Store the data being processed.
- * @throws DecoderException
- * Thrown when an unrecoverable error occurs.
- */
+ * This method, when called, execute an action on the current data
+ * stored in the container.
+ *
+ * @param asn1Container
+ * Store the data being processed.
+ * @throws DecoderException
+ * Thrown when an unrecoverable error occurs.
+ */
// void executeAction( ConnectionParserContainer container ) throws
- // Exception;
+ // Exception;
/**
- * Get the grammar name
- *
- * @return Return the grammar's name
- */
+ * Get the grammar name
+ *
+ * @return Return the grammar's name
+ */
String getName();
+
/**
- * Set the grammar's name
- *
- * @param name
- * The grammar name
- */
- void setName(String name);
+ * Set the grammar's name
+ *
+ * @param name
+ * The grammar name
+ */
+ void setName( String name );
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/Tag.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/Tag.java?view=diff&rev=488371&r1=488370&r2=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/Tag.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/Tag.java Mon Dec 18 09:57:38 2006
@@ -20,13 +20,15 @@
package org.apache.directory.ldapstudio.browser.model;
+
/**
* This class represent a XML Tag which consists of : - a name - a type (START,
* END)
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class Tag {
+public class Tag
+{
private String name;
@@ -36,52 +38,73 @@
public static int END = 1;
- public Tag(String name, int type) {
- setName(name);
- setType(type);
+
+ public Tag( String name, int type )
+ {
+ setName( name );
+ setType( type );
}
- public String getName() {
- return name;
+
+ public String getName()
+ {
+ return name;
}
- public void setName(String name) {
- this.name = name.toLowerCase();
+
+ public void setName( String name )
+ {
+ this.name = name.toLowerCase();
}
- public int getType() {
- return type;
+
+ public int getType()
+ {
+ return type;
}
- public void setType(int type) {
- this.type = type;
+
+ public void setType( int type )
+ {
+ this.type = type;
}
+
@Override
- public boolean equals(Object obj) {
- if (obj instanceof Tag) {
- Tag tag = (Tag) obj;
- return ((this.name.equals(tag.getName())) && (this.type == tag
- .getType()));
-
- } else {
- return false;
- }
+ public boolean equals( Object obj )
+ {
+ if ( obj instanceof Tag )
+ {
+ Tag tag = ( Tag ) obj;
+ return ( ( this.name.equals( tag.getName() ) ) && ( this.type == tag.getType() ) );
+
+ }
+ else
+ {
+ return false;
+ }
}
+
@Override
- public int hashCode() {
+ public int hashCode()
+ {
- return name.hashCode() + type << 24;
+ return name.hashCode() + type << 24;
}
+
@Override
- public String toString() {
- if (name != null) {
- return "<" + ((type == Tag.END) ? "/" : "") + name + ">";
- } else {
- return "Unknown tag";
- }
+ public String toString()
+ {
+ if ( name != null )
+ {
+ return "<" + ( ( type == Tag.END ) ? "/" : "" ) + name + ">";
+ }
+ else
+ {
+ return "Unknown tag";
+ }
}
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/ImageKeys.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/ImageKeys.java?view=diff&rev=488371&r1=488370&r2=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/ImageKeys.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/ImageKeys.java Mon Dec 18 09:57:38 2006
@@ -20,12 +20,14 @@
package org.apache.directory.ldapstudio.browser.view;
+
/**
* This class is used to define path for images
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class ImageKeys {
+public class ImageKeys
+{
// Images for Views
public static final String CONNECTION = "resources/icons/connection.gif"; //$NON-NLS-1$
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesView.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesView.java?view=diff&rev=488371&r1=488370&r2=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesView.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesView.java Mon Dec 18 09:57:38 2006
@@ -80,7 +80,7 @@
tree.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true ) );
tree.setLinesVisible( true );
tree.setHeaderVisible( true );
-// tree.setEnabled( false ); // The table is disabled by default since nothing is selected in the Browser View
+ // tree.setEnabled( false ); // The table is disabled by default since nothing is selected in the Browser View
viewer = new TreeViewer( tree );
viewer.setUseHashlookup( true );
@@ -101,14 +101,14 @@
// Registering the view to the controller and creating the Actions
controller.setView( this );
-// controller.createActions();
+ // controller.createActions();
// Registering the Viewer, so other views can be notified when the viewer selection changes
getSite().setSelectionProvider( viewer );
-// createContextMenu();
+ // createContextMenu();
-// createToolbarButtons();
+ // createToolbarButtons();
}
@@ -126,7 +126,7 @@
{
AttributeWrapper at1 = ( AttributeWrapper ) o1;
AttributeWrapper at2 = ( AttributeWrapper ) o2;
-
+
return at1.getName().compareTo( at2.getName() );
}
return 0;
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewContentProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewContentProvider.java?view=diff&rev=488371&r1=488370&r2=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewContentProvider.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewContentProvider.java Mon Dec 18 09:57:38 2006
@@ -100,7 +100,7 @@
if ( parentElement instanceof AttributeWrapper )
{
return ( ( AttributeWrapper ) parentElement ).getChildren();
-
+
}
return null;
}
@@ -120,8 +120,8 @@
{
if ( element instanceof AttributeWrapper )
{
- return ( ( AttributeWrapper ) element).hasChildren();
-
+ return ( ( AttributeWrapper ) element ).hasChildren();
+
}
return false;
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewLabelProvider.java?view=diff&rev=488371&r1=488370&r2=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewLabelProvider.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewLabelProvider.java Mon Dec 18 09:57:38 2006
@@ -40,7 +40,8 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class AttributesViewLabelProvider extends LabelProvider implements ITableLabelProvider, ITableFontProvider, ITableColorProvider
+public class AttributesViewLabelProvider extends LabelProvider implements ITableLabelProvider, ITableFontProvider,
+ ITableColorProvider
{
/* (non-Javadoc)
@@ -68,14 +69,14 @@
// Default return (should never be used)
return "";
}
-
+
public Font getFont( Object element, int columnIndex )
{
- if ( ( element instanceof AttributeWrapper ) && ( columnIndex == 1 ) )
- {
+ if ( ( element instanceof AttributeWrapper ) && ( columnIndex == 1 ) )
+ {
AttributeWrapper attributeWrapper = ( AttributeWrapper ) element;
-
+
if ( attributeWrapper.getChildren().length > 1 )
{
return new Font( null, "Geneva", 9, SWT.ITALIC );
@@ -94,13 +95,13 @@
public Color getForeground( Object element, int columnIndex )
{
- if ( ( element instanceof AttributeWrapper ) && ( columnIndex == 1 ) )
- {
+ if ( ( element instanceof AttributeWrapper ) && ( columnIndex == 1 ) )
+ {
AttributeWrapper attributeWrapper = ( AttributeWrapper ) element;
-
+
if ( attributeWrapper.getChildren().length > 1 )
{
- return PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_GRAY);
+ return PlatformUI.getWorkbench().getDisplay().getSystemColor( SWT.COLOR_GRAY );
}
}
return null;
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeValueWrapper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeValueWrapper.java?view=diff&rev=488371&r1=488370&r2=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeValueWrapper.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeValueWrapper.java Mon Dec 18 09:57:38 2006
@@ -1,5 +1,6 @@
package org.apache.directory.ldapstudio.browser.view.views.wrappers;
+
/**
* AttributeValueWrapper used to display an attribute value in the Attributes
* View
@@ -7,40 +8,51 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class AttributeValueWrapper {
+public class AttributeValueWrapper
+{
private Object value;
private AttributeWrapper parent;
- public AttributeValueWrapper(Object value, AttributeWrapper parent) {
- this.value = value;
- this.parent = parent;
+
+ public AttributeValueWrapper( Object value, AttributeWrapper parent )
+ {
+ this.value = value;
+ this.parent = parent;
}
+
/*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
- * int)
- */
- public String getColumnText(Object element, int columnIndex) {
- if (columnIndex == 0) {
- return ""; // The first column needs an entry String
- } else if (columnIndex == 1) {
- if (value instanceof String) {
- return (String) value;
- }
- }
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
+ * int)
+ */
+ public String getColumnText( Object element, int columnIndex )
+ {
+ if ( columnIndex == 0 )
+ {
+ return ""; // The first column needs an entry String
+ }
+ else if ( columnIndex == 1 )
+ {
+ if ( value instanceof String )
+ {
+ return ( String ) value;
+ }
+ }
- return "";
+ return "";
}
+
/**
- * Gets the parent element
- *
- * @return the parent element
- */
- public AttributeWrapper getParent() {
- return parent;
+ * Gets the parent element
+ *
+ * @return the parent element
+ */
+ public AttributeWrapper getParent()
+ {
+ return parent;
}
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeWrapper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeWrapper.java?view=diff&rev=488371&r1=488370&r2=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeWrapper.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeWrapper.java Mon Dec 18 09:57:38 2006
@@ -20,6 +20,7 @@
package org.apache.directory.ldapstudio.browser.view.views.wrappers;
+
import java.util.ArrayList;
import java.util.List;
@@ -27,6 +28,7 @@
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
+
/**
* AttributeWrapper used to display an attribute and the number of its values in
* the Attributes View
@@ -34,99 +36,124 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class AttributeWrapper {
+public class AttributeWrapper
+{
private Attribute attribute;
private EntryWrapper entry;
private List<AttributeValueWrapper> children;
+
/**
- * Creates a new instance of AttributeWrapper.
- *
- * @param attribute
- * the attribute to wrap
- * @param entry
- * the associated EntryWrapper
- */
- public AttributeWrapper(Attribute attribute, EntryWrapper entry) {
- this.attribute = attribute;
- this.entry = entry;
+ * Creates a new instance of AttributeWrapper.
+ *
+ * @param attribute
+ * the attribute to wrap
+ * @param entry
+ * the associated EntryWrapper
+ */
+ public AttributeWrapper( Attribute attribute, EntryWrapper entry )
+ {
+ this.attribute = attribute;
+ this.entry = entry;
}
+
/**
- * Gets the children of the object
- *
- * @return the children of the object
- */
- public Object[] getChildren() {
- if (children == null) {
- children = new ArrayList<AttributeValueWrapper>();
-
- try {
- NamingEnumeration ne = attribute.getAll();
-
- while (ne.hasMoreElements()) {
- AttributeValueWrapper avw = new AttributeValueWrapper(ne
- .nextElement(), this);
- children.add(avw);
- }
- } catch (NamingException e) {
- // TODO Add a log into Eclipse system
- e.printStackTrace();
- }
- }
- return children.toArray();
+ * Gets the children of the object
+ *
+ * @return the children of the object
+ */
+ public Object[] getChildren()
+ {
+ if ( children == null )
+ {
+ children = new ArrayList<AttributeValueWrapper>();
+
+ try
+ {
+ NamingEnumeration ne = attribute.getAll();
+
+ while ( ne.hasMoreElements() )
+ {
+ AttributeValueWrapper avw = new AttributeValueWrapper( ne.nextElement(), this );
+ children.add( avw );
+ }
+ }
+ catch ( NamingException e )
+ {
+ // TODO Add a log into Eclipse system
+ e.printStackTrace();
+ }
+ }
+ return children.toArray();
}
+
/*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
- * int)
- */
- public String getColumnText(Object element, int columnIndex) {
- if (columnIndex == 0) {
- return attribute.getID();
- } else if (columnIndex == 1) {
- int nb = getChildren().length;
- if (nb == 1) {
- // If there's only one value we display it
- try {
- Object value;
- value = attribute.get();
- if (value instanceof String) {
- return (String) value;
-
- }
- return "(Binary value)";
-
- } catch (NamingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- } else {
- return "(" + nb + " attributes)";
- }
- }
- return "";
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
+ * int)
+ */
+ public String getColumnText( Object element, int columnIndex )
+ {
+ if ( columnIndex == 0 )
+ {
+ return attribute.getID();
+ }
+ else if ( columnIndex == 1 )
+ {
+ int nb = getChildren().length;
+ if ( nb == 1 )
+ {
+ // If there's only one value we display it
+ try
+ {
+ Object value;
+ value = attribute.get();
+ if ( value instanceof String )
+ {
+ return ( String ) value;
+
+ }
+ return "(Binary value)";
+
+ }
+ catch ( NamingException e )
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ else
+ {
+ return "(" + nb + " attributes)";
+ }
+ }
+ return "";
}
+
/**
- * Gets the HasChildren Flag
- *
- * @return
- */
- public boolean hasChildren() {
- return (getChildren().length > 1);
+ * Gets the HasChildren Flag
+ *
+ * @return
+ */
+ public boolean hasChildren()
+ {
+ return ( getChildren().length > 1 );
}
+
/**
- * Gets the name of the attribute
- *
- * @return the name of the attribute
- */
- public String getName() {
- return attribute.getID();
+ * Gets the name of the attribute
+ *
+ * @return the name of the attribute
+ */
+ public String getName()
+ {
+ return attribute.getID();
}
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/ConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/ConnectionWrapper.java?view=diff&rev=488371&r1=488370&r2=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/ConnectionWrapper.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/ConnectionWrapper.java Mon Dec 18 09:57:38 2006
@@ -20,6 +20,7 @@
package org.apache.directory.ldapstudio.browser.view.views.wrappers;
+
import java.util.ArrayList;
import java.util.List;
@@ -40,22 +41,24 @@
import org.apache.directory.ldapstudio.dsmlv2.reponse.ErrorResponse;
import org.apache.directory.ldapstudio.dsmlv2.reponse.SearchResponse;
+
/**
* ConnectionWrapper used to display a Connection in the TreeViewer of the
* Browser View
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class ConnectionWrapper implements Comparable<ConnectionWrapper>,
- DisplayableTreeViewerElement {
+public class ConnectionWrapper implements Comparable<ConnectionWrapper>, DisplayableTreeViewerElement
+{
/**
- * This enum represents the different states of a ConnectionWrapper
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory
- * Project</a>
- */
- public enum ConnectionWrapperState {
- NONE, RUNNING, ERROR
+ * This enum represents the different states of a ConnectionWrapper
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory
+ * Project</a>
+ */
+ public enum ConnectionWrapperState
+ {
+ NONE, RUNNING, ERROR
}
/** The parent element */
@@ -73,241 +76,260 @@
/** The DSML Engine used to connect to the server */
private Dsmlv2Engine engine;
+
/**
- * Creates a new instance of ConnectionWrapper.
- *
- * @param connection
- * the connection to wrap
- */
- public ConnectionWrapper(Connection connection) {
- this.connection = connection;
- this.state = ConnectionWrapperState.NONE;
+ * Creates a new instance of ConnectionWrapper.
+ *
+ * @param connection
+ * the connection to wrap
+ */
+ public ConnectionWrapper( Connection connection )
+ {
+ this.connection = connection;
+ this.state = ConnectionWrapperState.NONE;
}
+
/*
- * (non-Javadoc)
- *
- * @see org.apache.directory.ldapstudio.browser.view.views.wrappers.DisplayableTreeViewerElement#getDisplayName()
- */
- public String getDisplayName() {
- return connection.getName();
+ * (non-Javadoc)
+ *
+ * @see org.apache.directory.ldapstudio.browser.view.views.wrappers.DisplayableTreeViewerElement#getDisplayName()
+ */
+ public String getDisplayName()
+ {
+ return connection.getName();
}
+
/*
- * (non-Javadoc)
- *
- * @see org.apache.directory.ldapstudio.browser.view.views.wrappers.DisplayableTreeViewerElement#getDisplayImage()
- */
- public Image getDisplayImage() {
- if (state == ConnectionWrapperState.NONE) {
- return AbstractUIPlugin.imageDescriptorFromPlugin(
- Activator.PLUGIN_ID, ImageKeys.CONNECTION).createImage();
- } else if (state == ConnectionWrapperState.RUNNING) {
- return AbstractUIPlugin.imageDescriptorFromPlugin(
- Activator.PLUGIN_ID, ImageKeys.CONNECTION_RUNNING)
- .createImage();
- } else if (state == ConnectionWrapperState.ERROR) {
- return AbstractUIPlugin.imageDescriptorFromPlugin(
- Activator.PLUGIN_ID, ImageKeys.CONNECTION_ERROR)
- .createImage();
- }
+ * (non-Javadoc)
+ *
+ * @see org.apache.directory.ldapstudio.browser.view.views.wrappers.DisplayableTreeViewerElement#getDisplayImage()
+ */
+ public Image getDisplayImage()
+ {
+ if ( state == ConnectionWrapperState.NONE )
+ {
+ return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.CONNECTION )
+ .createImage();
+ }
+ else if ( state == ConnectionWrapperState.RUNNING )
+ {
+ return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.CONNECTION_RUNNING )
+ .createImage();
+ }
+ else if ( state == ConnectionWrapperState.ERROR )
+ {
+ return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.CONNECTION_ERROR )
+ .createImage();
+ }
- return AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID,
- ImageKeys.CONNECTION).createImage();
+ return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.CONNECTION ).createImage();
}
+
/**
- * Gets the wrapped connection
- *
- * @return the wrapped connection
- */
- public Connection getConnection() {
- return connection;
+ * Gets the wrapped connection
+ *
+ * @return the wrapped connection
+ */
+ public Connection getConnection()
+ {
+ return connection;
}
+
/*
- * (non-Javadoc)
- *
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo(ConnectionWrapper o) {
- ConnectionWrapper otherWrapper = (ConnectionWrapper) o;
- return getDisplayName().compareToIgnoreCase(
- otherWrapper.getDisplayName());
+ * (non-Javadoc)
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( ConnectionWrapper o )
+ {
+ ConnectionWrapper otherWrapper = ( ConnectionWrapper ) o;
+ return getDisplayName().compareToIgnoreCase( otherWrapper.getDisplayName() );
}
+
/**
- * Get parent object in the TreeViewer Hierarchy
- *
- * @return the parent
- */
- public Object getParent() {
- return parent;
+ * Get parent object in the TreeViewer Hierarchy
+ *
+ * @return the parent
+ */
+ public Object getParent()
+ {
+ return parent;
}
+
/**
- * Set the parent object in the TreeViewer Hierarchy
- *
- * @param parent
- * the parent element
- */
- public void setParent(Object parent) {
- this.parent = parent;
- }
-
- public Object[] getChildren() {
- if (children == null) {
- children = new ArrayList<EntryWrapper>();
-
- // Getting the Browser View
- BrowserView browserView = (BrowserView) PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().findView(
- BrowserView.ID);
-
- try {
- if (engine == null) {
- // Initialization of the DSML Engine and the DSML
- // Response Parser
- if (connection.isAppendBaseDNtoUserDNWithBaseDN()) {
- engine = new Dsmlv2Engine(connection.getHost(),
- connection.getPort(), new LdapDN(connection
- .getUserDN().getNormName()
- + ","
- + connection.getBaseDN().getNormName())
- .getNormName(), connection
- .getPassword());
- } else {
- engine = new Dsmlv2Engine(connection.getHost(),
- connection.getPort(), connection.getUserDN()
- .getNormName(), connection
- .getPassword());
- }
- }
-
- Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser();
-
- String request = "<batchRequest>"
- + " <searchRequest dn=\""
- + connection.getBaseDN().getNormName()
- + "\""
- + " scope=\"baseObject\" derefAliases=\"neverDerefAliases\">"
- + " <filter><present name=\"objectclass\"></present></filter>"
- + " <attributes>" + " <attribute name=\"*\"/>"
- + " <attribute name=\"namingContexts\"/>"
- + " <attribute name=\"subSchemaSubEntry\"/>"
- + " <attribute name=\"altServer\"/>"
- + " <attribute name=\"supportedExtension\"/>"
- + " <attribute name=\"supportedControl\"/>"
- + " <attribute name=\"supportedSaslMechanism\"/>"
- + " <attribute name=\"supportedLdapVersion\"/>"
- + " </attributes>" + " </searchRequest>"
- + "</batchRequest>";
+ * Set the parent object in the TreeViewer Hierarchy
+ *
+ * @param parent
+ * the parent element
+ */
+ public void setParent( Object parent )
+ {
+ this.parent = parent;
+ }
- // Executing the request and sending the result to the Response
- // Parser
- parser.setInput(engine.processDSML(request));
- parser.parse();
- LdapResponse ldapResponse = parser.getBatchResponse()
- .getCurrentResponse();
+ public Object[] getChildren()
+ {
+ if ( children == null )
+ {
+ children = new ArrayList<EntryWrapper>();
+
+ // Getting the Browser View
+ BrowserView browserView = ( BrowserView ) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().findView( BrowserView.ID );
+
+ try
+ {
+ if ( engine == null )
+ {
+ // Initialization of the DSML Engine and the DSML
+ // Response Parser
+ if ( connection.isAppendBaseDNtoUserDNWithBaseDN() )
+ {
+ engine = new Dsmlv2Engine( connection.getHost(), connection.getPort(), new LdapDN( connection
+ .getUserDN().getNormName()
+ + "," + connection.getBaseDN().getNormName() ).getNormName(), connection.getPassword() );
+ }
+ else
+ {
+ engine = new Dsmlv2Engine( connection.getHost(), connection.getPort(), connection.getUserDN()
+ .getNormName(), connection.getPassword() );
+ }
+ }
+
+ Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser();
+
+ String request = "<batchRequest>" + " <searchRequest dn=\"" + connection.getBaseDN().getNormName()
+ + "\"" + " scope=\"baseObject\" derefAliases=\"neverDerefAliases\">"
+ + " <filter><present name=\"objectclass\"></present></filter>" + " <attributes>"
+ + " <attribute name=\"*\"/>" + " <attribute name=\"namingContexts\"/>"
+ + " <attribute name=\"subSchemaSubEntry\"/>" + " <attribute name=\"altServer\"/>"
+ + " <attribute name=\"supportedExtension\"/>" + " <attribute name=\"supportedControl\"/>"
+ + " <attribute name=\"supportedSaslMechanism\"/>"
+ + " <attribute name=\"supportedLdapVersion\"/>" + " </attributes>" + " </searchRequest>"
+ + "</batchRequest>";
- if (ldapResponse instanceof SearchResponse) {
- SearchResponse searchResponse = (SearchResponse) ldapResponse;
+ // Executing the request and sending the result to the Response
+ // Parser
+ parser.setInput( engine.processDSML( request ) );
+ parser.parse();
- LdapResult ldapResult = searchResponse
- .getSearchResultDone().getLdapResult();
-
- if (ldapResult.getResultCode() == 0) {
- // Getting the Base DN
- SearchResultEntry baseDN = ((SearchResponse) ldapResponse)
- .getCurrentSearchResultEntry();
-
- EntryWrapper baseDNWrapper = new EntryWrapper(baseDN);
- baseDNWrapper.setParent(this);
- baseDNWrapper.setIsBaseDN(true);
-
- children.add(baseDNWrapper);
-
- setState(ConnectionWrapperState.RUNNING);
- browserView.getViewer().update(this, null);
- } else {
- setState(ConnectionWrapperState.ERROR);
- clearChildren();
- browserView.getViewer().update(this, null);
-
- // Displaying an error
- MessageDialog.openError(PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell(),
- "Error !", "An error has ocurred.\n"
- + ldapResult.getErrorMessage());
- return null;
- }
- } else if (ldapResponse instanceof ErrorResponse) {
- setState(ConnectionWrapperState.ERROR);
- children = new ArrayList<EntryWrapper>(0);
- browserView.getViewer().update(this, null);
-
- ErrorResponse errorResponse = (ErrorResponse) ldapResponse;
- // Displaying an error
- MessageDialog.openError(PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell(), "Error !",
- "An error has ocurred.\n"
- + errorResponse.getMessage());
-
- return null;
- }
- } catch (Exception e) {
- // Displaying an error
- MessageDialog.openError(PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell(), "Error !",
- "An error has ocurred.\n" + e.getMessage());
- return null;
- }
- }
+ LdapResponse ldapResponse = parser.getBatchResponse().getCurrentResponse();
- return children.toArray(new Object[0]);
+ if ( ldapResponse instanceof SearchResponse )
+ {
+ SearchResponse searchResponse = ( SearchResponse ) ldapResponse;
+
+ LdapResult ldapResult = searchResponse.getSearchResultDone().getLdapResult();
+
+ if ( ldapResult.getResultCode() == 0 )
+ {
+ // Getting the Base DN
+ SearchResultEntry baseDN = ( ( SearchResponse ) ldapResponse ).getCurrentSearchResultEntry();
+
+ EntryWrapper baseDNWrapper = new EntryWrapper( baseDN );
+ baseDNWrapper.setParent( this );
+ baseDNWrapper.setIsBaseDN( true );
+
+ children.add( baseDNWrapper );
+
+ setState( ConnectionWrapperState.RUNNING );
+ browserView.getViewer().update( this, null );
+ }
+ else
+ {
+ setState( ConnectionWrapperState.ERROR );
+ clearChildren();
+ browserView.getViewer().update( this, null );
+
+ // Displaying an error
+ MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ "Error !", "An error has ocurred.\n" + ldapResult.getErrorMessage() );
+ return null;
+ }
+ }
+ else if ( ldapResponse instanceof ErrorResponse )
+ {
+ setState( ConnectionWrapperState.ERROR );
+ children = new ArrayList<EntryWrapper>( 0 );
+ browserView.getViewer().update( this, null );
+
+ ErrorResponse errorResponse = ( ErrorResponse ) ldapResponse;
+ // Displaying an error
+ MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ "Error !", "An error has ocurred.\n" + errorResponse.getMessage() );
+
+ return null;
+ }
+ }
+ catch ( Exception e )
+ {
+ // Displaying an error
+ MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error !",
+ "An error has ocurred.\n" + e.getMessage() );
+ return null;
+ }
+ }
+
+ return children.toArray( new Object[0] );
}
+
/**
- * Erases the Children List
- */
- public void clearChildren() {
- children = null;
+ * Erases the Children List
+ */
+ public void clearChildren()
+ {
+ children = null;
}
+
/**
- * Erases the Children List and the Dsmlv2 Engine
- */
- public void connectionChanged() {
- clearChildren();
- engine = null;
+ * Erases the Children List and the Dsmlv2 Engine
+ */
+ public void connectionChanged()
+ {
+ clearChildren();
+ engine = null;
}
+
/**
- * Sets the current state of the ConnectionWrapper
- *
- * @param state
- * the state to set
- */
- public void setState(ConnectionWrapperState state) {
- this.state = state;
+ * Sets the current state of the ConnectionWrapper
+ *
+ * @param state
+ * the state to set
+ */
+ public void setState( ConnectionWrapperState state )
+ {
+ this.state = state;
}
+
/**
- * Gets the current state of the ConnectionWrapper
- *
- * @return the state of the ConnectionWrapper
- */
- public ConnectionWrapperState getState() {
- return this.state;
+ * Gets the current state of the ConnectionWrapper
+ *
+ * @return the state of the ConnectionWrapper
+ */
+ public ConnectionWrapperState getState()
+ {
+ return this.state;
}
+
/**
- * Gets the Dsmlv2Engine
- *
- * @return the Dsmlv2Engine
- */
- public Dsmlv2Engine getDsmlv2Engine() {
- return this.engine;
+ * Gets the Dsmlv2Engine
+ *
+ * @return the Dsmlv2Engine
+ */
+ public Dsmlv2Engine getDsmlv2Engine()
+ {
+ return this.engine;
}
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/DisplayableTreeViewerElement.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/DisplayableTreeViewerElement.java?view=diff&rev=488371&r1=488370&r2=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/DisplayableTreeViewerElement.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/DisplayableTreeViewerElement.java Mon Dec 18 09:57:38 2006
@@ -20,49 +20,56 @@
package org.apache.directory.ldapstudio.browser.view.views.wrappers;
+
import org.apache.directory.ldapstudio.browser.model.Connection;
import org.eclipse.swt.graphics.Image;
+
/**
* All objects that want to be displayed in the JFace TreeViewer should
* implement this interface.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public interface DisplayableTreeViewerElement {
+public interface DisplayableTreeViewerElement
+{
/**
- * Get the image that should be displayed in the TreeViewer
- *
- * @return the display image
- */
+ * Get the image that should be displayed in the TreeViewer
+ *
+ * @return the display image
+ */
public Image getDisplayImage();
+
/**
- * Get the name that should be displayed in the TreeViewer
- *
- * @return the display name
- */
+ * Get the name that should be displayed in the TreeViewer
+ *
+ * @return the display name
+ */
public String getDisplayName();
+
/**
- * Get parent object in the TreeViewer Hierarchy
- *
- * @return the parent
- */
+ * Get parent object in the TreeViewer Hierarchy
+ *
+ * @return the parent
+ */
public Object getParent();
+
/**
- * Set the parent object in the TreeViewer Hierarchy
- *
- * @param parent
- * the parent element
- */
- public void setParent(Object parent);
+ * Set the parent object in the TreeViewer Hierarchy
+ *
+ * @param parent
+ * the parent element
+ */
+ public void setParent( Object parent );
+
/**
- * Gets the children of the object
- *
- * @return the children of the object
- */
+ * Gets the children of the object
+ *
+ * @return the children of the object
+ */
public Object[] getChildren();
}