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 2008/05/28 17:55:15 UTC
svn commit: r660993 - in
/directory/studio/branches/apacheds-plugin-branch/apacheds: ./ META-INF/
src/main/java/org/apache/directory/studio/apacheds/
src/main/java/org/apache/directory/studio/apacheds/actions/
src/main/java/org/apache/directory/studio/...
Author: pamarcelot
Date: Wed May 28 08:55:14 2008
New Revision: 660993
URL: http://svn.apache.org/viewvc?rev=660993&view=rev
Log:
o Added a 'Rename' action
o Updated the 'Delete' action to delete the directory associated to the server on disk.
Added:
directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RenameAction.java
Modified:
directory/studio/branches/apacheds-plugin-branch/apacheds/META-INF/MANIFEST.MF
directory/studio/branches/apacheds-plugin-branch/apacheds/pom.xml
directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginConstants.java
directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/DeleteAction.java
directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/OpenAction.java
directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/model/ServersHandler.java
directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/views/ServersView.java
Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/META-INF/MANIFEST.MF?rev=660993&r1=660992&r2=660993&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/META-INF/MANIFEST.MF (original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/META-INF/MANIFEST.MF Wed May 28 08:55:14 2008
@@ -8,6 +8,7 @@
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.ui.console,
+ org.eclipse.ui.ide,
org.eclipse.jface.text,
org.eclipse.jdt.launching,
org.eclipse.debug.core,
Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/pom.xml?rev=660993&r1=660992&r2=660993&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/pom.xml (original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/pom.xml Wed May 28 08:55:14 2008
@@ -658,6 +658,11 @@
<artifactId>launching</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.eclipse.ui</groupId>
+ <artifactId>ide</artifactId>
+ <scope>provided</scope>
+ </dependency>
<!-- Apache Directory Studio dependencies -->
<dependency>
<groupId>org.apache.directory.studio</groupId>
Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginConstants.java?rev=660993&r1=660992&r2=660993&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginConstants.java (original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginConstants.java Wed May 28 08:55:14 2008
@@ -55,6 +55,7 @@
public static final String ACTION_PROPERTIES = "org.apache.directory.studio.apacheds.actions.propertiesAction";
public static final String ACTION_OPEN = "org.apache.directory.studio.apacheds.actions.openAction";
public static final String ACTION_DELETE = "org.apache.directory.studio.apacheds.actions.deleteAction";
+ public static final String ACTION_RENAME = "org.apache.directory.studio.apacheds.actions.renameAction";
// -----------
// PREFERENCES
Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/DeleteAction.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/DeleteAction.java?rev=660993&r1=660992&r2=660993&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/DeleteAction.java (original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/DeleteAction.java Wed May 28 08:55:14 2008
@@ -20,7 +20,10 @@
package org.apache.directory.studio.apacheds.actions;
+import java.io.File;
+
import org.apache.directory.studio.apacheds.ApacheDsPluginConstants;
+import org.apache.directory.studio.apacheds.ApacheDsPluginUtils;
import org.apache.directory.studio.apacheds.dialogs.DeleteServerDialog;
import org.apache.directory.studio.apacheds.model.ServerInstance;
import org.apache.directory.studio.apacheds.model.ServersHandler;
@@ -73,15 +76,49 @@
StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
// Here's the real object
- ServerInstance serverInstance = ( ServerInstance ) selection.getFirstElement();
+ ServerInstance server = ( ServerInstance ) selection.getFirstElement();
// Asking for confirmation
- DeleteServerDialog dsd = new DeleteServerDialog( view.getSite().getShell(), serverInstance );
+ DeleteServerDialog dsd = new DeleteServerDialog( view.getSite().getShell(), server );
if ( dsd.open() == DeleteServerDialog.OK )
{
- // Removing the server instance
- ServersHandler.getDefault().removeServerInstance( serverInstance );
+ // Removing the server
+ ServersHandler.getDefault().removeServerInstance( server );
+
+ // Deleting the associated directory on disk
+ deleteDirectory( new File( ApacheDsPluginUtils.getApacheDsInstancesFolder().append( server.getId() )
+ .toOSString() ) );
+ }
+ }
+
+
+ /**
+ * Deletes the given directory
+ *
+ * @param path
+ * the directory
+ * @return
+ * <code>true</code> if and only if the directory is
+ * successfully deleted; <code>false</code> otherwise
+ */
+ private boolean deleteDirectory( File path )
+ {
+ if ( path.exists() )
+ {
+ File[] files = path.listFiles();
+ for ( int i = 0; i < files.length; i++ )
+ {
+ if ( files[i].isDirectory() )
+ {
+ deleteDirectory( files[i] );
+ }
+ else
+ {
+ files[i].delete();
+ }
+ }
}
+ return ( path.delete() );
}
Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/OpenAction.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/OpenAction.java?rev=660993&r1=660992&r2=660993&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/OpenAction.java (original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/OpenAction.java Wed May 28 08:55:14 2008
@@ -92,7 +92,6 @@
{
// TODO
}
-
}
}
Added: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RenameAction.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RenameAction.java?rev=660993&view=auto
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RenameAction.java (added)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RenameAction.java Wed May 28 08:55:14 2008
@@ -0,0 +1,367 @@
+/*
+ * 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.
+ *
+ */
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.apache.directory.studio.apacheds.actions;
+
+
+import org.apache.directory.studio.apacheds.ApacheDsPluginConstants;
+import org.apache.directory.studio.apacheds.model.ServerInstance;
+import org.apache.directory.studio.apacheds.model.ServersHandler;
+import org.apache.directory.studio.apacheds.views.ServersView;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TreeEditor;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.actions.TextActionHandler;
+
+
+/**
+ * This class implements the open action for a server.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class RenameAction extends Action implements IWorkbenchWindowActionDelegate
+{
+ /** The associated view */
+ private ServersView view;
+ private Tree tree;
+ private TreeEditor treeEditor;
+ protected Composite textEditorParent;
+ protected Text textEditor;
+ private TextActionHandler textActionHandler;
+ // The server being edited if this is being done inline
+ protected ServerInstance editedServer;
+
+ protected boolean saving = false;
+
+
+ /**
+ * Creates a new instance of OpenAction.
+ *
+ * @param view
+ * the associated view
+ */
+ public RenameAction( ServersView view )
+ {
+ super( "Rename..." );
+ this.view = view;
+ this.tree = view.getViewer().getTree();
+ this.treeEditor = new TreeEditor( tree );
+ setToolTipText( "Rename..." );
+ setId( ApacheDsPluginConstants.ACTION_RENAME );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run()
+ {
+ // What we get from the TableViewer is a StructuredSelection
+ StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
+
+ // Here's the real object
+ ServerInstance server = ( ServerInstance ) selection.getFirstElement();
+ if ( server != null )
+ {
+ queryNewServerNameInline( server );
+ }
+ }
+
+
+ /**
+ * Return the new name to be given to the target resource or
+ * <code>null<code>
+ * if the query was canceled. Rename the currently selected server using the table editor.
+ * Continue the action when the user is done.
+ *
+ * @param server the server to rename
+ */
+ private void queryNewServerNameInline( final ServerInstance server )
+ {
+ // Make sure text editor is created only once. Simply reset text
+ // editor when action is executed more than once. Fixes bug 22269
+ if ( textEditorParent == null )
+ {
+ createTextEditor( server );
+ }
+ textEditor.setText( server.getName() );
+
+ // Open text editor with initial size
+ textEditorParent.setVisible( true );
+ Point textSize = textEditor.computeSize( SWT.DEFAULT, SWT.DEFAULT );
+ textSize.x += textSize.y; // Add extra space for new characters
+ Point parentSize = textEditorParent.getSize();
+ int inset = getCellEditorInset( textEditorParent );
+ textEditor.setBounds( 2, inset, Math.min( textSize.x, parentSize.x - 4 ), parentSize.y - 2 * inset );
+ textEditorParent.redraw();
+ textEditor.selectAll();
+ textEditor.setFocus();
+ }
+
+
+ /**
+ * Create the text editor widget.
+ *
+ * @param server the server to rename
+ */
+ private void createTextEditor( final ServerInstance server )
+ {
+ // Create text editor parent. This draws a nice bounding rect
+ textEditorParent = createParent();
+ textEditorParent.setVisible( false );
+ final int inset = getCellEditorInset( textEditorParent );
+ if ( inset > 0 )
+ {
+ textEditorParent.addListener( SWT.Paint, new Listener()
+ {
+ public void handleEvent( Event e )
+ {
+ Point textSize = textEditor.getSize();
+ Point parentSize = textEditorParent.getSize();
+ e.gc.drawRectangle( 0, 0, Math.min( textSize.x + 4, parentSize.x - 1 ), parentSize.y - 1 );
+ }
+ } );
+ }
+ // Create inner text editor
+ textEditor = new Text( textEditorParent, SWT.NONE );
+ textEditor.setFont( tree.getFont() );
+ textEditorParent.setBackground( textEditor.getBackground() );
+ textEditor.addListener( SWT.Modify, new Listener()
+ {
+ public void handleEvent( Event e )
+ {
+ Point textSize = textEditor.computeSize( SWT.DEFAULT, SWT.DEFAULT );
+ textSize.x += textSize.y; // Add extra space for new
+ // characters.
+ Point parentSize = textEditorParent.getSize();
+ textEditor.setBounds( 2, inset, Math.min( textSize.x, parentSize.x - 4 ), parentSize.y - 2 * inset );
+ textEditorParent.redraw();
+ }
+ } );
+ textEditor.addListener( SWT.Traverse, new Listener()
+ {
+ public void handleEvent( Event event )
+ {
+
+ // Workaround for Bug 20214 due to extra
+ // traverse events
+ switch ( event.detail )
+ {
+ case SWT.TRAVERSE_ESCAPE:
+ // Do nothing in this case
+ disposeTextWidget();
+ event.doit = true;
+ event.detail = SWT.TRAVERSE_NONE;
+ break;
+ case SWT.TRAVERSE_RETURN:
+ saveChangesAndDispose( server );
+ event.doit = true;
+ event.detail = SWT.TRAVERSE_NONE;
+ break;
+ }
+ }
+ } );
+ textEditor.addFocusListener( new FocusAdapter()
+ {
+ public void focusLost( FocusEvent fe )
+ {
+ saveChangesAndDispose( server );
+ }
+ } );
+
+ if ( textActionHandler != null )
+ {
+ textActionHandler.addText( textEditor );
+ }
+ }
+
+
+ private Composite createParent()
+ {
+ Tree tree2 = tree;
+ Composite result = new Composite( tree2, SWT.NONE );
+ TreeItem[] selectedItems = tree2.getSelection();
+ treeEditor.horizontalAlignment = SWT.LEFT;
+ treeEditor.grabHorizontal = true;
+ treeEditor.setEditor( result, selectedItems[0] );
+ return result;
+ }
+
+
+ /**
+ * Close the text widget and reset the editorText field.
+ */
+ protected void disposeTextWidget()
+ {
+ if ( textActionHandler != null )
+ textActionHandler.removeText( textEditor );
+
+ if ( textEditorParent != null )
+ {
+ textEditorParent.dispose();
+ textEditorParent = null;
+ textEditor = null;
+ treeEditor.setEditor( null, null );
+ }
+ }
+
+
+ /**
+ * Save the changes and dispose of the text widget.
+ *
+ * @param server the server to rename
+ */
+ protected void saveChangesAndDispose( ServerInstance server )
+ {
+ if ( saving == true )
+ return;
+
+ saving = true;
+ // Cache the resource to avoid selection loss since a selection of
+ // another item can trigger this method
+ editedServer = server;
+ final String newName = textEditor.getText();
+ // Run this in an async to make sure that the operation that triggered
+ // this action is completed. Otherwise this leads to problems when the
+ // icon of the item being renamed is clicked (i.e., which causes the
+ // rename text widget to lose focus and trigger this method)
+ tree.getShell().getDisplay().asyncExec( new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ if ( !newName.equals( editedServer.getName() ) )
+ {
+ if ( !ServersHandler.getDefault().isNameAvailable( newName ) )
+ {
+ MessageDialog.openError( tree.getShell(), "Server",
+ "The name is already in use. Specify a different name." );
+ }
+ else
+ {
+ editedServer.setName( newName );
+ }
+ }
+ editedServer = null;
+ // Dispose the text widget regardless
+ disposeTextWidget();
+ // Ensure the Navigator tree has focus, which it may not if
+ // the text widget previously had focus
+ if ( tree != null && !tree.isDisposed() )
+ {
+ tree.setFocus();
+ }
+ }
+ finally
+ {
+ saving = false;
+ }
+ }
+ } );
+ }
+
+
+ /**
+ * On Mac the text widget already provides a border when it has focus, so
+ * there is no need to draw another one. The value of returned by this
+ * method is usd to control the inset we apply to the text field bound's in
+ * order to get space for drawing a border. A value of 1 means a one-pixel
+ * wide border around the text field. A negative value supresses the border.
+ * However, in M9 the system property
+ * "org.eclipse.swt.internal.carbon.noFocusRing" has been introduced as a
+ * temporary workaround for bug #28842. The existence of the property turns
+ * the native focus ring off if the widget is contained in a main window
+ * (not dialog). The check for the property should be removed after a final
+ * fix for #28842 has been provided.
+ */
+ private static int getCellEditorInset( Control c )
+ {
+ // special case for MacOS X
+ if ( "carbon".equals( SWT.getPlatform() ) ) { //$NON-NLS-1$
+ if ( System.getProperty( "org.eclipse.swt.internal.carbon.noFocusRing" ) == null || c.getShell().getParent() != null ) { //$NON-NLS-1$
+ return -2; // native border
+ }
+ }
+ return 1; // one pixel wide black border
+ }
+
+
+ /* (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/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/model/ServersHandler.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/model/ServersHandler.java?rev=660993&r1=660992&r2=660993&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/model/ServersHandler.java (original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/model/ServersHandler.java Wed May 28 08:55:14 2008
@@ -52,10 +52,7 @@
/** The list of server instances */
private List<ServerInstance> serverInstancesList;
-
- /** The map of server instances identified by name */
- private Map<String, ServerInstance> serverInstancesNameMap;
-
+
/** The map of server instances identified by ID */
private Map<String, ServerInstance> serverInstancesIdMap;
@@ -70,7 +67,6 @@
{
// Initializing lists and maps
serverInstancesList = new ArrayList<ServerInstance>();
- serverInstancesNameMap = new HashMap<String, ServerInstance>();
serverInstancesIdMap = new HashMap<String, ServerInstance>();
listeners = new ArrayList<ServersHandlerListener>();
}
@@ -123,7 +119,6 @@
// Adding the server instance
serverInstancesList.add( serverInstance );
serverInstancesIdMap.put( serverInstance.getId(), serverInstance );
- serverInstancesNameMap.put( serverInstance.getName(), serverInstance );
// Notifying listeners
if ( notifyListeners )
@@ -165,9 +160,8 @@
if ( serverInstancesList.contains( serverInstance ) )
{
// Removing the server instance
- serverInstancesNameMap.remove( serverInstance.getName() );
- serverInstancesIdMap.remove( serverInstance.getId() );
serverInstancesList.remove( serverInstance );
+ serverInstancesIdMap.remove( serverInstance.getId() );
// Notifying listeners
if ( notifyListeners )
@@ -305,7 +299,15 @@
*/
public boolean isNameAvailable( String name )
{
- return !serverInstancesNameMap.containsKey( name );
+ for ( ServerInstance server : serverInstancesList )
+ {
+ if ( server.getName().equalsIgnoreCase( name ) )
+ {
+ return false;
+ }
+ }
+
+ return true;
}
Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/views/ServersView.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/views/ServersView.java?rev=660993&r1=660992&r2=660993&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/views/ServersView.java (original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/views/ServersView.java Wed May 28 08:55:14 2008
@@ -24,6 +24,7 @@
import org.apache.directory.studio.apacheds.actions.NewServerInstanceAction;
import org.apache.directory.studio.apacheds.actions.OpenAction;
import org.apache.directory.studio.apacheds.actions.PropertiesAction;
+import org.apache.directory.studio.apacheds.actions.RenameAction;
import org.apache.directory.studio.apacheds.actions.ServerInstanceRunAction;
import org.apache.directory.studio.apacheds.actions.ServerInstanceStopAction;
import org.apache.directory.studio.apacheds.model.ServerInstance;
@@ -67,11 +68,14 @@
/** The ID of the view */
public static final String ID = "org.apache.directory.studio.apacheds.serversView";
+ /** The tree*/
+ private Tree tree;
+
/** The table viewer */
private ServersTableViewer tableViewer;
private static final String TAG_COLUMN_WIDTH = "columnWidth";
- protected int[] cols;
+ protected int[] columnWidths;
// Actions
private NewServerInstanceAction newServerInstance;
@@ -80,6 +84,7 @@
private PropertiesAction properties;
private DeleteAction delete;
private OpenAction open;
+ private RenameAction rename;
// Listeners
private ServersHandlerListener serversHandlerListener = new ServersHandlerListener()
@@ -111,8 +116,6 @@
}
};
- private Tree tree;
-
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
@@ -128,14 +131,14 @@
// Adding columns
TreeColumn serverColumn = new TreeColumn( tree, SWT.SINGLE );
serverColumn.setText( "Server" );
- serverColumn.setWidth( cols[0] );
+ serverColumn.setWidth( columnWidths[0] );
serverColumn.addSelectionListener( getHeaderListener( 0 ) );
tree.setSortColumn( serverColumn );
tree.setSortDirection( SWT.UP );
TreeColumn stateColumn = new TreeColumn( tree, SWT.SINGLE );
stateColumn.setText( "State" );
- stateColumn.setWidth( cols[1] );
+ stateColumn.setWidth( columnWidths[1] );
stateColumn.addSelectionListener( getHeaderListener( 1 ) );
// Creating the viewer
@@ -180,7 +183,7 @@
public void init( IViewSite site, IMemento memento ) throws PartInitException
{
super.init( site, memento );
- cols = new int[]
+ columnWidths = new int[]
{ 200, 60 };
for ( int i = 0; i < 2; i++ )
{
@@ -189,7 +192,7 @@
Integer in = memento.getInteger( TAG_COLUMN_WIDTH + i );
if ( in != null && in.intValue() > 5 )
{
- cols[i] = in.intValue();
+ columnWidths[i] = in.intValue();
}
}
}
@@ -246,6 +249,9 @@
delete = new DeleteAction( this );
delete.setEnabled( false );
+
+ rename = new RenameAction( this );
+ rename.setEnabled( false );
}
@@ -279,6 +285,7 @@
manager.add( open );
manager.add( new Separator() );
manager.add( delete );
+ manager.add( rename );
manager.add( new Separator() );
manager.add( serverInstanceRun );
manager.add( serverInstanceStop );
@@ -361,6 +368,7 @@
open.setEnabled( true );
delete.setEnabled( true );
properties.setEnabled( true );
+ rename.setEnabled( true );
}
else
{
@@ -369,6 +377,7 @@
open.setEnabled( false );
delete.setEnabled( false );
properties.setEnabled( false );
+ rename.setEnabled( false );
}
}