directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r659550 - in /directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations: ./ resources/icons/ src/main/java/org/apache/directory/studio/apacheds/experimentations/ src/main/java/org/apache/directory/studio/apacheds/...
Date Fri, 23 May 2008 14:34:06 GMT
Author: pamarcelot
Date: Fri May 23 07:34:04 2008
New Revision: 659550

URL: http://svn.apache.org/viewvc?rev=659550&view=rev
Log:
Improved the Servers View:
    o Added new icons for the servers
    o Added a server state
    o Added a property page for the servers.

Added:
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server.gif
  (with props)
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_started.gif
  (with props)
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_starting1.gif
  (with props)
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_starting2.gif
  (with props)
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_starting3.gif
  (with props)
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_stopped.gif
  (with props)
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_stopping1.gif
  (with props)
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_stopping2.gif
  (with props)
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_stopping3.gif
  (with props)
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/actions/PropertiesAction.java
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServerStateEnum.java
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/properties/
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/properties/ServerInstancePropertyPage.java
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/views/ServersViewContentProvider.java
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/views/ServersViewLabelProvider.java
Modified:
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/plugin.xml
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ApacheDsPluginConstants.java
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServerInstance.java
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/views/ServersView.java

Modified: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/plugin.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/plugin.xml?rev=659550&r1=659549&r2=659550&view=diff
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/plugin.xml
(original)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/plugin.xml
Fri May 23 07:34:04 2008
@@ -43,5 +43,13 @@
             name="Servers">
       </view>
    </extension>
+   <extension
+         point="org.eclipse.ui.propertyPages">
+      <page
+            class="org.apache.directory.studio.apacheds.experimentations.properties.ServerInstancePropertyPage"
+            id="org.apache.directory.studio.apacheds.experimentations.properties.serverInstanceProperties"
+            name="Info">
+      </page>
+   </extension>
 
 </plugin>

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server.gif
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server.gif?rev=659550&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_started.gif
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_started.gif?rev=659550&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_started.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_starting1.gif
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_starting1.gif?rev=659550&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_starting1.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_starting2.gif
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_starting2.gif?rev=659550&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_starting2.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_starting3.gif
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_starting3.gif?rev=659550&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_starting3.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_stopped.gif
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_stopped.gif?rev=659550&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_stopped.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_stopping1.gif
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_stopping1.gif?rev=659550&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_stopping1.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_stopping2.gif
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_stopping2.gif?rev=659550&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_stopping2.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_stopping3.gif
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_stopping3.gif?rev=659550&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/resources/icons/server_stopping3.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ApacheDsPluginConstants.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ApacheDsPluginConstants.java?rev=659550&r1=659549&r2=659550&view=diff
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ApacheDsPluginConstants.java
(original)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ApacheDsPluginConstants.java
Fri May 23 07:34:04 2008
@@ -33,6 +33,15 @@
     // -------
     public static final String IMG_SERVER_INSTANCE = "resources/icons/server-instance.png";
     public static final String IMG_SERVER_INSTANCE_NEW = "resources/icons/server-instance-new.png";
+    public static final String IMG_SERVER = "resources/icons/server.gif";
+    public static final String IMG_SERVER_STARTED = "resources/icons/server_started.gif";
+    public static final String IMG_SERVER_STARTING1 = "resources/icons/server_starting1.gif";
+    public static final String IMG_SERVER_STARTING2 = "resources/icons/server_starting2.gif";
+    public static final String IMG_SERVER_STARTING3 = "resources/icons/server_starting3.gif";
+    public static final String IMG_SERVER_STOPPED = "resources/icons/server_stopped.gif";
+    public static final String IMG_SERVER_STOPPING1 = "resources/icons/server_stopping1.gif";
+    public static final String IMG_SERVER_STOPPING2 = "resources/icons/server_stopping2.gif";
+    public static final String IMG_SERVER_STOPPING3 = "resources/icons/server_stopping3.gif";
     public static final String IMG_RUN = "resources/icons/run.gif";
     public static final String IMG_STOP = "resources/icons/stop.gif";
 
@@ -42,8 +51,8 @@
     public static final String ACTION_NEW_SERVER_INSTANCE = "org.apache.directory.studio.apacheds.experimentations.actions.newServerInstanceAction";
     public static final String ACTION_SERVER_INSTANCE_RUN = "org.apache.directory.studio.apacheds.experimentations.actions.serverInstanceRunAction";
     public static final String ACTION_SERVER_INSTANCE_STOP = "org.apache.directory.studio.apacheds.experimentations.actions.serverInstanceStopAction";
-    
-    
+    public static final String ACTION_PROPERTIES = "org.apache.directory.studio.apacheds.experimentations.actions.propertiesAction";
+
     // -----------
     // PREFERENCES
     // -----------

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/actions/PropertiesAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/actions/PropertiesAction.java?rev=659550&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/actions/PropertiesAction.java
(added)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/actions/PropertiesAction.java
Fri May 23 07:34:04 2008
@@ -0,0 +1,175 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.experimentations.actions;
+
+
+import org.apache.directory.studio.apacheds.experimentations.ApacheDsPluginConstants;
+import org.apache.directory.studio.apacheds.experimentations.model.ServerInstance;
+import org.apache.directory.studio.apacheds.experimentations.views.ServersView;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+
+/**
+ * This class implements the properties action for a server instance.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PropertiesAction extends Action implements IWorkbenchWindowActionDelegate
+{
+    /** The associated view */
+    private ServersView view;
+
+
+    /**
+     * Creates a new instance of NewServerInstanceAction.
+     */
+    public PropertiesAction( ServersView view )
+    {
+        super( "Properties" );
+        this.view = view;
+        setToolTipText( "Properties" );
+        setId( ApacheDsPluginConstants.ACTION_PROPERTIES );
+        setEnabled( false );
+
+        view.getViewer().addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            /* (non-Javadoc)
+             * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+             */
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                StructuredSelection selection = ( StructuredSelection ) event.getSelection();
+                setEnabled( !selection.isEmpty() );
+            }
+        } );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.action.Action#run()
+     */
+    public void run()
+    {
+        StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
+        if ( !selection.isEmpty() )
+        {
+            ServerInstance serverInstance = ( ServerInstance ) selection.getFirstElement();
+            PreferenceDialog dialog = PreferencesUtil
+                .createPropertyDialogOn( view.getViewSite().getShell(), serverInstance,
+                    "org.apache.directory.studio.apacheds.experimentations.properties.serverInstanceProperties",
null,
+                    null );
+            dialog.getShell().setText( "Properties for '" + shorten( serverInstance.getName(),
30 ) + "'" );
+            dialog.open();
+        }
+    }
+
+
+    /**
+     * Shortens the given label to the given maximum length
+     * and filters non-printable characters.
+     * 
+     * @param label the label
+     * @param maxLength the max length
+     * 
+     * @return the shortened label
+     */
+    public static String shorten( String label, int maxLength )
+    {
+        if ( label == null )
+        {
+            return null;
+        }
+
+        // shorten label
+        if ( maxLength < 3 )
+        {
+            return "...";
+        }
+        if ( label.length() > maxLength )
+        {
+            label = label.substring( 0, maxLength / 2 ) + "..."
+                + label.substring( label.length() - maxLength / 2, label.length() );
+
+        }
+
+        // filter non-printable characters
+        StringBuffer sb = new StringBuffer( maxLength + 3 );
+        for ( int i = 0; i < label.length(); i++ )
+        {
+            char c = label.charAt( i );
+            if ( Character.isISOControl( c ) )
+            {
+                sb.append( '.' );
+            }
+            else
+            {
+                sb.append( c );
+            }
+        }
+
+        return sb.toString();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+     */
+    public void run( IAction action )
+    {
+        run();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+     */
+    public void dispose()
+    {
+        // Nothing to do
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+     */
+    public void init( IWorkbenchWindow window )
+    {
+        // Nothing to do
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
org.eclipse.jface.viewers.ISelection)
+     */
+    public void selectionChanged( IAction action, ISelection selection )
+    {
+        // Nothing to do
+    }
+}

Modified: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServerInstance.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServerInstance.java?rev=659550&r1=659549&r2=659550&view=diff
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServerInstance.java
(original)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServerInstance.java
Fri May 23 07:34:04 2008
@@ -22,6 +22,8 @@
 
 import java.util.UUID;
 
+import org.eclipse.core.runtime.IAdaptable;
+
 
 /**
  * This class represents an Apache DS instance.
@@ -29,14 +31,17 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class ServerInstance
+public class ServerInstance implements IAdaptable
 {
     /** The name of the instance */
     private String name;
 
-    /** The ID of the instance*/
+    /** The ID of the instance */
     private String id;
 
+    /** The state of the instance */
+    private ServerStateEnum state = ServerStateEnum.STOPPED;
+
 
     /**
      * Creates a new instance of ApacheDsInstance.
@@ -134,4 +139,35 @@
     {
         return UUID.randomUUID().toString();
     }
+
+
+    /**
+     * Gets the state.
+     *
+     * @return
+     *      the state
+     */
+    public ServerStateEnum getState()
+    {
+        return state;
+    }
+
+
+    /**
+     * Sets the state
+     *
+     * @param state
+     *      the state
+     */
+    public void setState( ServerStateEnum state )
+    {
+        this.state = state;
+    }
+
+
+    public Object getAdapter( Class adapter )
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServerStateEnum.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServerStateEnum.java?rev=659550&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServerStateEnum.java
(added)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServerStateEnum.java
Fri May 23 07:34:04 2008
@@ -0,0 +1,56 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.experimentations.model;
+
+
+/**
+ * This enum defines the different states that a server can take.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public enum ServerStateEnum
+{
+    STARTING("Starting"), STARTED("Started"), STOPPING("Stopping"), STOPPED("Stopped"), UNKNONW("Unknown");
+
+    /** The dispayable name of the state */
+    private String displayName;
+
+
+    /**
+     * Creates a new instance of ServerStateEnum.
+     *
+     * @param displayName
+     *      the display name
+     */
+    private ServerStateEnum( String displayName )
+    {
+        this.displayName = displayName;
+    }
+
+
+    /* (non-Javadoc)
+     * @see java.lang.Enum#toString()
+     */
+    public String toString()
+    {
+        return displayName;
+    }
+}

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/properties/ServerInstancePropertyPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/properties/ServerInstancePropertyPage.java?rev=659550&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/properties/ServerInstancePropertyPage.java
(added)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/properties/ServerInstancePropertyPage.java
Fri May 23 07:34:04 2008
@@ -0,0 +1,112 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.experimentations.properties;
+
+
+import org.apache.directory.studio.apacheds.experimentations.ApacheDsPluginUtils;
+import org.apache.directory.studio.apacheds.experimentations.model.ServerInstance;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+
+/**
+ * This class implements the 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ServerInstancePropertyPage extends PropertyPage implements IWorkbenchPropertyPage
+{
+    /**
+     * Creates a new instance of ServerInstancePropertyPage.
+     */
+    public ServerInstancePropertyPage()
+    {
+        super();
+        super.noDefaultAndApplyButton();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+     */
+    protected Control createContents( Composite parent )
+    {
+        // Composite
+        Composite composite = new Composite( parent, SWT.NONE );
+        composite.setLayout( new GridLayout( 2, false ) );
+        composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+
+        // Name
+        Label nameLabel = new Label( composite, SWT.NONE );
+        nameLabel.setText( "Name:" );
+        Text nameText = createLabeledText( composite, "", 1 );
+        nameText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Location
+        Label locationLabel = new Label( composite, SWT.NONE );
+        locationLabel.setText( "Location" );
+        Text locationText = createLabeledText( composite, "", 1 );
+        locationText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Getting the server instance
+        ServerInstance serverInstance = ( ServerInstance ) getElement();
+        if ( serverInstance != null )
+        {
+            nameText.setText( serverInstance.getName() );
+            locationText.setText( ApacheDsPluginUtils.getApacheDsInstancesFolder().append(
serverInstance.getId() )
+                .toOSString() );
+        }
+
+        return parent;
+    }
+
+
+    /**
+     * Creates a SWT {@link Text} under the given parent.
+     * The created text control behaves like a label: it has no border, 
+     * a grayed background and is not modifyable. 
+     * But the text is selectable and could be copied.
+     *
+     * @param parent the parent
+     * @param text the initial text
+     * @param span the horizontal span
+     * @return the created text
+     */
+    public static Text createLabeledText( Composite parent, String text, int span )
+    {
+        Text t = new Text( parent, SWT.NONE );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = span;
+        t.setLayoutData( gd );
+        t.setEditable( false );
+        t.setBackground( parent.getBackground() );
+        t.setText( text );
+        return t;
+    }
+}

Modified: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/views/ServersView.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/views/ServersView.java?rev=659550&r1=659549&r2=659550&view=diff
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/views/ServersView.java
(original)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/views/ServersView.java
Fri May 23 07:34:04 2008
@@ -21,10 +21,9 @@
 
 
 import org.apache.directory.studio.apacheds.configuration.editor.ServerConfigurationEditor;
-import org.apache.directory.studio.apacheds.experimentations.ApacheDsPlugin;
-import org.apache.directory.studio.apacheds.experimentations.ApacheDsPluginConstants;
 import org.apache.directory.studio.apacheds.experimentations.ApacheDsPluginUtils;
 import org.apache.directory.studio.apacheds.experimentations.actions.NewServerInstanceAction;
+import org.apache.directory.studio.apacheds.experimentations.actions.PropertiesAction;
 import org.apache.directory.studio.apacheds.experimentations.actions.ServerInstanceRunAction;
 import org.apache.directory.studio.apacheds.experimentations.actions.ServerInstanceStopAction;
 import org.apache.directory.studio.apacheds.experimentations.model.ServerInstance;
@@ -32,22 +31,27 @@
 import org.apache.directory.studio.apacheds.experimentations.model.ServersHandlerListener;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
 import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IMemento;
 import org.eclipse.ui.IPathEditorInput;
 import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchActionConstants;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
@@ -68,12 +72,16 @@
     public static final String ID = "org.apache.directory.studio.apacheds.experimentations.serversView";
 
     /** The table viewer */
-    private TableViewer tableViewer;
+    private TreeViewer tableViewer;
+
+    private static final String TAG_COLUMN_WIDTH = "columnWidth";
+    protected int[] cols;
 
     // Actions
     private NewServerInstanceAction newServerInstance;
     private ServerInstanceRunAction serverInstanceRun;
     private ServerInstanceStopAction serverInstanceStop;
+    private PropertiesAction properties;
 
     // Listeners
     private ServersHandlerListener serversHandlerListener = new ServersHandlerListener()
@@ -111,57 +119,75 @@
      */
     public void createPartControl( Composite parent )
     {
-        tableViewer = new TableViewer( parent );
-        tableViewer.getTable().setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true
) );
-        tableViewer.setContentProvider( new ArrayContentProvider() );
-        tableViewer.setLabelProvider( new LabelProvider()
-        {
-            /* (non-Javadoc)
-             * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
-             */
-            public Image getImage( Object element )
-            {
-                if ( element instanceof ServerInstance )
-                {
-                    return ApacheDsPlugin.getDefault().getImage( ApacheDsPluginConstants.IMG_SERVER_INSTANCE
);
-                }
-
-                // Default
-                return super.getImage( element );
-            }
-
-
-            /* (non-Javadoc)
-             * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
-             */
-            public String getText( Object element )
-            {
-                if ( element instanceof ServerInstance )
-                {
-                    ServerInstance serverInstance = ( ServerInstance ) element;
-
-                    return serverInstance.getName();
-                }
+        // Creating the table viewer
+        tableViewer = new TreeViewer( parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL
| SWT.V_SCROLL );
+        Tree table = tableViewer.getTree();
+        table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+        table.setHeaderVisible( true );
+        table.setLinesVisible( false );
+
+        // Adding columns
+        TreeColumn serverColumn = new TreeColumn( table, SWT.SINGLE );
+        serverColumn.setText( "Server" );
+        serverColumn.setWidth( cols[0] );
+
+        TreeColumn stateColumn = new TreeColumn( table, SWT.SINGLE );
+        stateColumn.setText( "State" );
+        stateColumn.setWidth( cols[1] );
 
-                // Default
-                return super.getText( element );
-            }
-        } );
+        tableViewer.setContentProvider( new ServersViewContentProvider() );
+        tableViewer.setLabelProvider( new ServersViewLabelProvider() );
         //        tableViewer.setSorter( new ViewerComparator() );
 
         initActions();
         initToolbar();
+        initContextMenu();
         initUI();
         initListeners();
     }
 
 
     /* (non-Javadoc)
+     * @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite, org.eclipse.ui.IMemento)
+     */
+    public void init( IViewSite site, IMemento memento ) throws PartInitException
+    {
+        super.init( site, memento );
+        cols = new int[2];
+        for ( int i = 0; i < 2; i++ )
+        {
+            cols[i] = 200;
+            if ( memento != null )
+            {
+                Integer in = memento.getInteger( TAG_COLUMN_WIDTH + i );
+                if ( in != null && in.intValue() > 5 )
+                    cols[i] = in.intValue();
+            }
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.ViewPart#saveState(org.eclipse.ui.IMemento)
+     */
+    public void saveState( IMemento memento )
+    {
+        TreeColumn[] tc = tableViewer.getTree().getColumns();
+        for ( int i = 0; i < 2; i++ )
+        {
+            int width = tc[i].getWidth();
+            if ( width != 0 )
+                memento.putInteger( TAG_COLUMN_WIDTH + i, width );
+        }
+    }
+
+
+    /* (non-Javadoc)
      * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
      */
     public void setFocus()
     {
-        tableViewer.getTable().setFocus();
+        tableViewer.getTree().setFocus();
     }
 
 
@@ -173,6 +199,7 @@
         newServerInstance = new NewServerInstanceAction();
         serverInstanceRun = new ServerInstanceRunAction( this );
         serverInstanceStop = new ServerInstanceStopAction( this );
+        properties = new PropertiesAction( this );
     }
 
 
@@ -190,6 +217,36 @@
 
 
     /**
+     * Initializes the Context Menu.
+     */
+    private void initContextMenu()
+    {
+        MenuManager contextMenu = new MenuManager( "" ); //$NON-NLS-1$
+        contextMenu.setRemoveAllWhenShown( true );
+        contextMenu.addMenuListener( new IMenuListener()
+        {
+            public void menuAboutToShow( IMenuManager manager )
+            {
+                MenuManager newManager = new MenuManager( "New" );
+                newManager.add( newServerInstance );
+                manager.add( newManager );
+                manager.add( new Separator() );
+                manager.add( serverInstanceRun );
+                manager.add( serverInstanceStop );
+                manager.add( new Separator() );
+                manager.add( properties );
+            }
+        } );
+
+        // set the context menu to the table viewer
+        tableViewer.getControl().setMenu( contextMenu.createContextMenu( tableViewer.getControl()
) );
+
+        // register the context menu to enable extension actions
+        getSite().registerContextMenu( contextMenu, tableViewer );
+    }
+
+
+    /**
      * Initializes the user interface with the servers instances.
      */
     private void initUI()
@@ -217,8 +274,6 @@
 
                 // Here's the real object
                 ServerInstance serverInstance = ( ServerInstance ) selection.getFirstElement();
-                IEditorInput input = null;
-                String editorId = null;
 
                 IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                 try
@@ -242,7 +297,7 @@
      * @return
      *      the table viewer
      */
-    public TableViewer getViewer()
+    public TreeViewer getViewer()
     {
         return tableViewer;
     }

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/views/ServersViewContentProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/views/ServersViewContentProvider.java?rev=659550&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/views/ServersViewContentProvider.java
(added)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/views/ServersViewContentProvider.java
Fri May 23 07:34:04 2008
@@ -0,0 +1,99 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.experimentations.views;
+
+
+import java.util.Collection;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+
+/**
+ * This class implements the content provider for the Servers view.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ServersViewContentProvider implements IStructuredContentProvider, ITreeContentProvider
+{
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+     */
+    public Object[] getElements( Object inputElement )
+    {
+        if ( inputElement instanceof Object[] )
+        {
+            return ( Object[] ) inputElement;
+        }
+        else if ( inputElement instanceof Collection )
+        {
+            return ( ( Collection<?> ) inputElement ).toArray();
+        }
+
+        return new Object[0];
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+     */
+    public void dispose()
+    {
+        // Nothing to do
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
java.lang.Object, java.lang.Object)
+     */
+    public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+    {
+        // Nothing to do
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+     */
+    public Object[] getChildren( Object parentElement )
+    {
+        return null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+     */
+    public Object getParent( Object element )
+    {
+        return null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+     */
+    public boolean hasChildren( Object element )
+    {
+        return false;
+    }
+}

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/views/ServersViewLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/views/ServersViewLabelProvider.java?rev=659550&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/views/ServersViewLabelProvider.java
(added)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/views/ServersViewLabelProvider.java
Fri May 23 07:34:04 2008
@@ -0,0 +1,93 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.experimentations.views;
+
+
+import org.apache.directory.studio.apacheds.experimentations.ApacheDsPlugin;
+import org.apache.directory.studio.apacheds.experimentations.ApacheDsPluginConstants;
+import org.apache.directory.studio.apacheds.experimentations.model.ServerInstance;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+
+/**
+ * This class implements the label provider for the Servers view.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ServersViewLabelProvider extends LabelProvider implements ITableLabelProvider
+{
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
int)
+     */
+    public String getColumnText( Object element, int columnIndex )
+    {
+        if ( element instanceof ServerInstance )
+        {
+            ServerInstance serverInstance = ( ServerInstance ) element;
+            if ( columnIndex == 0 )
+            {
+                return serverInstance.getName();
+            }
+            else if ( columnIndex == 1 )
+            {
+                return serverInstance.getState().toString();
+            }
+
+        }
+
+        return null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object,
int)
+     */
+    public Image getColumnImage( Object element, int columnIndex )
+    {
+        if ( element instanceof ServerInstance )
+        {
+            if ( columnIndex == 0 )
+            {
+                return ApacheDsPlugin.getDefault().getImage( ApacheDsPluginConstants.IMG_SERVER
);
+            }
+            else if ( columnIndex == 1 )
+            {
+                switch ( ( ( ServerInstance ) element ).getState() )
+                {
+                    case STARTED:
+                        return ApacheDsPlugin.getDefault().getImage( ApacheDsPluginConstants.IMG_SERVER_STARTED
);
+                    case STARTING:
+                        return ApacheDsPlugin.getDefault().getImage( ApacheDsPluginConstants.IMG_SERVER_STARTING2
);
+                    case STOPPED:
+                        return ApacheDsPlugin.getDefault().getImage( ApacheDsPluginConstants.IMG_SERVER_STOPPED
);
+                    case STOPPING:
+                        return ApacheDsPlugin.getDefault().getImage( ApacheDsPluginConstants.IMG_SERVER_STOPPING2
);
+                    case UNKNONW:
+                        return ApacheDsPlugin.getDefault().getImage( ApacheDsPluginConstants.IMG_SERVER
);
+                }
+            }
+        }
+
+        return null;
+    }
+}



Mime
View raw message