[458349] Consolidate UI 

Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=458349
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutContentProvider.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutContentProvider.java
index bb27c5e..40488a4 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutContentProvider.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutContentProvider.java
@@ -78,8 +78,10 @@
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
@@ -87,6 +89,8 @@
  */
 public class CDOCheckoutContentProvider extends AdapterFactoryContentProvider implements IOpenListener
 {
+  private static final Set<Object> LOADING_OBJECTS = new HashSet<Object>();
+
   private static final Method GET_CHILDREN_FEATURES_METHOD = getMethod(ItemProviderAdapter.class,
       "getChildrenFeatures", Object.class);
 
@@ -369,6 +373,11 @@
     final Object finalObject = object;
     final CDOCheckout finalOpeningCheckout = openingCheckout;
 
+    synchronized (LOADING_OBJECTS)
+    {
+      LOADING_OBJECTS.add(originalObject);
+    }
+
     new Job("Load " + finalObject)
     {
       @Override
@@ -434,6 +443,12 @@
 
         // The viewer must be refreshed synchronously so that the loaded children don't get garbage collected.
         ViewerUtil.refresh(viewer, originalObject, false);
+
+        synchronized (LOADING_OBJECTS)
+        {
+          LOADING_OBJECTS.remove(originalObject);
+        }
+
         return Status.OK_STATUS;
       }
     }.schedule();
@@ -740,4 +755,12 @@
       return null;
     }
   }
+
+  public static boolean isObjectLoading(Object object)
+  {
+    synchronized (LOADING_OBJECTS)
+    {
+      return LOADING_OBJECTS.contains(object);
+    }
+  }
 }
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutNewActionProvider.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutNewActionProvider.java
index 053752e..1fd0b96 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutNewActionProvider.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutNewActionProvider.java
@@ -21,11 +21,13 @@
 import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor.NewRootMenuPopulator;
 import org.eclipse.emf.cdo.transaction.CDOTransaction;
 import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
 
 import org.eclipse.emf.common.command.BasicCommandStack;
 import org.eclipse.emf.common.util.EList;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.command.CommandParameter;
 import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
 import org.eclipse.emf.edit.domain.EditingDomain;
 import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
@@ -45,7 +47,9 @@
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
@@ -58,6 +62,7 @@
 import org.eclipse.ui.navigator.WizardActionGroup;
 
 import java.util.Collection;
+import java.util.LinkedList;
 
 /**
  * @author Eike Stepper
@@ -74,7 +79,7 @@
 
   private IWorkbenchPage page;
 
-  private StructuredViewer viewer;
+  private TreeViewer viewer;
 
   private Object selectedObject;
 
@@ -97,7 +102,7 @@
       newWizardActionGroup = new WizardActionGroup(window, PlatformUI.getWorkbench().getNewWizardRegistry(),
           WizardActionGroup.TYPE_NEW, extensionSite.getContentService());
 
-      viewer = extensionSite.getStructuredViewer();
+      viewer = (TreeViewer)extensionSite.getStructuredViewer();
       viewer.addSelectionChangedListener(this);
       updateSelectedObject(viewer.getSelection());
     }
@@ -233,77 +238,158 @@
     }
   }
 
+  private void selectObject(final EObject object)
+  {
+    viewer.getControl().getDisplay().asyncExec(new Runnable()
+    {
+      public void run()
+      {
+        LinkedList<EObject> path = new LinkedList<EObject>();
+        CDOCheckout checkout = CDOExplorerUtil.walkUp(object, path);
+        if (checkout != null)
+        {
+          viewer.setExpandedState(checkout, true);
+
+          path.removeFirst();
+          path.removeLast();
+
+          for (EObject object : path)
+          {
+            viewer.setExpandedState(object, true);
+          }
+
+          final Control control = viewer.getControl();
+          final Display display = control.getDisplay();
+          final long end = System.currentTimeMillis() + 1000L;
+
+          display.asyncExec(new Runnable()
+          {
+            public void run()
+            {
+              if (control.isDisposed())
+              {
+                return;
+              }
+
+              viewer.setSelection(new StructuredSelection(object), true);
+              if (viewer.getSelection().isEmpty())
+              {
+                if (CDOCheckoutContentProvider.isObjectLoading(object) || System.currentTimeMillis() < end)
+                {
+                  display.timerExec(50, this);
+                }
+              }
+            }
+          });
+        }
+      }
+    });
+  }
+
   /**
    * @author Eike Stepper
    */
-  private class NewRootAction extends TransactionalBackgroundAction
+  private abstract class AbstractNewAction extends TransactionalBackgroundAction
   {
-    private final EObject object;
+    private EObject newObject;
 
-    public NewRootAction(CDOResource resource, EObject object)
+    public AbstractNewAction(String text, String toolTipText, ImageDescriptor image, CDOObject parent)
     {
-      super(page, object.eClass().getName(), null, ExtendedImageRegistry.getInstance().getImageDescriptor(
-          CDOEditor.getLabelImage(adapterFactory, object)), resource);
-      this.object = object;
+      super(page, text, toolTipText, image, parent);
     }
 
     @Override
-    protected CDOTransaction openTransaction(CDOObject object)
+    protected CDOTransaction openTransaction(CDOObject AbstractNewAction)
     {
-      CDOCheckout checkout = CDOExplorerUtil.getCheckout(object);
+      CDOCheckout checkout = CDOExplorerUtil.getCheckout(AbstractNewAction);
       if (checkout != null)
       {
         return checkout.openTransaction();
       }
-    
+
       return null;
     }
 
     @Override
-    protected void doRun(CDOTransaction transaction, CDOObject resource, IProgressMonitor monitor) throws Exception
+    protected final void doRun(CDOTransaction transaction, CDOObject parent, IProgressMonitor monitor) throws Exception
     {
-      EList<EObject> contents = ((CDOResource)resource).getContents();
-      contents.add(object);
+      newObject = doRun(transaction, parent, new StructuredSelection(parent));
+    }
+
+    protected abstract EObject doRun(CDOTransaction transaction, CDOObject parent, ISelection selection);
+
+    @Override
+    protected void postRun(CDOView view, CDOObject parent)
+    {
+      if (newObject != null)
+      {
+        EObject object = view.getObject(newObject);
+        if (object != null)
+        {
+          selectObject(object);
+        }
+      }
     }
   }
 
   /**
    * @author Eike Stepper
    */
-  private class NewChildAction extends TransactionalBackgroundAction
+  private class NewRootAction extends AbstractNewAction
+  {
+    private final EObject object;
+
+    public NewRootAction(CDOResource resource, EObject object)
+    {
+      super(object.eClass().getName(), null, ExtendedImageRegistry.getInstance().getImageDescriptor(
+          CDOEditor.getLabelImage(adapterFactory, object)), resource);
+      this.object = object;
+    }
+
+    @Override
+    protected EObject doRun(CDOTransaction transaction, CDOObject resource, ISelection selection)
+    {
+      EList<EObject> contents = ((CDOResource)resource).getContents();
+      contents.add(object);
+      return object;
+    }
+  }
+
+  /**
+   * @author Eike Stepper
+   */
+  private class NewChildAction extends AbstractNewAction
   {
     private final Object childDescriptor;
 
     public NewChildAction(String text, String toolTipText, ImageDescriptor image, CDOObject parent,
         Object childDescriptor)
     {
-      super(page, text, toolTipText, image, parent);
+      super(text, toolTipText, image, parent);
       this.childDescriptor = childDescriptor;
     }
 
     @Override
-    protected CDOTransaction openTransaction(CDOObject object)
-    {
-      CDOCheckout checkout = CDOExplorerUtil.getCheckout(object);
-      if (checkout != null)
-      {
-        return checkout.openTransaction();
-      }
-
-      return null;
-    }
-
-    @Override
-    protected void doRun(CDOTransaction transaction, CDOObject parent, IProgressMonitor monitor) throws Exception
+    protected EObject doRun(CDOTransaction transaction, CDOObject parent, ISelection selection)
     {
       BasicCommandStack commandStack = new BasicCommandStack();
       ResourceSet resourceSet = transaction.getResourceSet();
       EditingDomain editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, resourceSet);
 
-      IStructuredSelection selection = new StructuredSelection(parent);
-
       CreateChildAction delegate = new CreateChildAction(editingDomain, selection, childDescriptor);
       delegate.run();
+
+      if (childDescriptor instanceof CommandParameter)
+      {
+        CommandParameter parameter = (CommandParameter)childDescriptor;
+        Object value = parameter.getValue();
+        if (value instanceof EObject)
+        {
+          return (EObject)value;
+        }
+      }
+
+      return null;
     }
   }
 }
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/RepositoryDeleteHandler.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/RepositoryDeleteHandler.java
index 7865881..f6f1df8 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/RepositoryDeleteHandler.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/RepositoryDeleteHandler.java
@@ -61,8 +61,9 @@
     {
       String plural = size == 1 ? "" : "s";
       String message = size == 1 ? "is 1" : "are " + size;
+
       if (MessageDialog.openQuestion(shell, "Existing Checkouts", "There " + message + " existing checkout" + plural
-          + ".\n\n" + "Are you sure you want to delete the existing checkout" + plural + ", too?"))
+          + ".\n\n" + "Are you sure you want to delete the checkout" + plural + ", too?"))
       {
         DeleteElementsDialog dialog = new DeleteElementsDialog(shell, checkouts.toArray(new AbstractElement[size]));
         if (dialog.open() == DeleteElementsDialog.OK)
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceRevertHandler.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceRevertHandler.java
index ac2c627..69ee685 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceRevertHandler.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceRevertHandler.java
@@ -25,6 +25,7 @@
 
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.dialogs.TitleAreaDialog;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.TreeViewer;
@@ -86,6 +87,22 @@
       }
 
       Shell shell = HandlerUtil.getActiveShell(event);
+
+      int size = dirtyTransactions.size();
+      if (size != 0)
+      {
+        String plural = size == 1 ? "" : "s";
+        String message = size == 1 ? "is 1" : "are " + size;
+
+        if (!MessageDialog.openQuestion(shell, "Uncommitted Transaction" + plural, "There " + message
+            + " uncommitted transaction" + plural + ".\n\n" + "Are you sure you want to rollback the transaction"
+            + plural + ", too?"))
+        {
+          cancel();
+          return;
+        }
+      }
+
       OfflineCDOCheckout checkout = elements.get(0);
       CDOChangeSetData revertData = workspace.getLocalChanges(false);
 
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/AbstractRepositoryPage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/AbstractRepositoryPage.java
index a38843c..ddca579 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/AbstractRepositoryPage.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/AbstractRepositoryPage.java
@@ -100,7 +100,7 @@
   protected final void validate()
   {
     properties = new Properties();
-    properties.put(CDORepositoryImpl.PROP_NAME, getName());
+    properties.put(CDORepositoryImpl.PROP_TYPE, getName());
 
     try
     {
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryLocalPage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryLocalPage.java
index 4d840a6..19cd076 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryLocalPage.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryLocalPage.java
@@ -10,11 +10,15 @@
  */
 package org.eclipse.emf.cdo.explorer.ui.repositories.wizards;
 
+import org.eclipse.emf.cdo.explorer.CDOExplorerUtil;
+import org.eclipse.emf.cdo.explorer.repositories.CDORepository;
+import org.eclipse.emf.cdo.explorer.repositories.CDORepositoryManager;
 import org.eclipse.emf.cdo.internal.explorer.repositories.LocalCDORepository;
 import org.eclipse.emf.cdo.internal.explorer.repositories.LocalCDORepository.IDGeneration;
 import org.eclipse.emf.cdo.internal.explorer.repositories.LocalCDORepository.VersioningMode;
 
 import org.eclipse.net4j.util.StringUtil;
+import org.eclipse.net4j.util.io.IOUtil;
 import org.eclipse.net4j.util.ui.widgets.TextAndDisable;
 
 import org.eclipse.swt.SWT;
@@ -26,13 +30,19 @@
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashSet;
 import java.util.Properties;
+import java.util.Set;
 
 /**
  * @author Eike Stepper
  */
 public class RepositoryLocalPage extends AbstractRepositoryPage
 {
+  private final Set<Integer> configuredPorts = new HashSet<Integer>();
+
   private Text nameText;
 
   private Button normalButton;
@@ -52,6 +62,28 @@
     super("local", "Local Repository 1");
     setTitle("New Local Repository");
     setMessage("Enter the label and the connection parameters of the new remote location.");
+
+    CDORepositoryManager repositoryManager = CDOExplorerUtil.getRepositoryManager();
+    for (CDORepository repository : repositoryManager.getRepositories())
+    {
+      try
+      {
+        URI uri = new URI(repository.getURI());
+        if ("tcp".equals(uri.getScheme()))
+        {
+          String host = uri.getHost();
+          if ("localhost".equals(host) || "127.0.0.1".equals(host))
+          {
+            configuredPorts.add(uri.getPort());
+          }
+        }
+      }
+      catch (URISyntaxException ex)
+      {
+        //$FALL-THROUGH$
+      }
+    }
+
   }
 
   @Override
@@ -79,7 +111,6 @@
 
     normalButton = new Button(modeGroup, SWT.RADIO);
     normalButton.setText("Normal (no history)");
-    normalButton.setSelection(true);
     normalButton.addSelectionListener(this);
 
     auditingButton = new Button(modeGroup, SWT.RADIO);
@@ -88,6 +119,7 @@
 
     branchingButton = new Button(modeGroup, SWT.RADIO);
     branchingButton.setText("Branching (history tree)");
+    branchingButton.setSelection(true);
     branchingButton.addSelectionListener(this);
 
     Group idGroup = new Group(composite, SWT.NONE);
@@ -97,17 +129,17 @@
 
     counterButton = new Button(idGroup, SWT.RADIO);
     counterButton.setText("Counter (efficient)");
-    counterButton.setSelection(true);
     counterButton.addSelectionListener(this);
 
     uuidButton = new Button(idGroup, SWT.RADIO);
     uuidButton.setText("UUID (replicable)");
+    uuidButton.setSelection(true);
     uuidButton.addSelectionListener(this);
 
     createLabel(container, "TCP port:");
     portText = new TextAndDisable(container, SWT.BORDER, null);
     portText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-    portText.setValue("2037");
+    portText.setValue(Integer.toString(getDefaultPort()));
     portText.setDisabled(true);
     portText.addModifyListener(this);
     portText.addSelectionListener(this);
@@ -148,23 +180,55 @@
       properties.put(LocalCDORepository.PROP_ID_GENERATION, IDGeneration.UUID.toString());
     }
 
-    String port = portText.getValue();
+    boolean tcpPortDisabled = portText.isDisabled();
+    properties.put(LocalCDORepository.PROP_TCP_DISABLED, Boolean.toString(tcpPortDisabled));
 
-    try
+    if (!tcpPortDisabled)
     {
-      int value = Integer.parseInt(port);
-      if (value < 0)
+      int port;
+
+      try
       {
-        throw new Exception();
+        port = Integer.parseInt(portText.getValue());
+        if (port < 0 || port > 0xffff)
+        {
+          throw new Exception();
+        }
+      }
+      catch (Exception ex)
+      {
+        throw new Exception("Invalid TCP port.");
+      }
+
+      if (!isFreePort(port))
+      {
+        throw new Exception("TCP port " + port + " is not available.");
+      }
+
+      properties.put(LocalCDORepository.PROP_TCP_PORT, port);
+    }
+  }
+
+  private int getDefaultPort()
+  {
+    for (int port = 2036; port < 0xffff; port++)
+    {
+      if (isFreePort(port))
+      {
+        return port;
       }
     }
-    catch (Exception ex)
+
+    return 2036;
+  }
+
+  private boolean isFreePort(int port)
+  {
+    if (configuredPorts.contains(port))
     {
-      throw new Exception("Invalid TCP port.");
+      return false;
     }
 
-    properties.put(LocalCDORepository.PROP_TCP_DISABLED, Boolean.toString(portText.isDisabled()));
-    properties.put(LocalCDORepository.PROP_TCP_PORT, port);
-
+    return IOUtil.isFreePort(port);
   }
 }
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryTypePage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryTypePage.java
index e9934ef..db9b1fd 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryTypePage.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryTypePage.java
@@ -54,23 +54,26 @@
     NewRepositoryWizard wizard = getWizard();
 
     RepositoryRemotePage remotePage = wizard.getRemotePage();
-    addChoice(composite, "Connect to an existing remote repository.", "icons/wiz/repo_remote.gif", remotePage);
+    addChoice(composite, "Connect to an existing remote repository.", "icons/wiz/repo_remote.gif", remotePage, true);
 
     RepositoryClonePage clonePage = wizard.getClonePage();
-    addChoice(composite, "Clone an existing remote repository.", "icons/wiz/repo_clone.gif", clonePage);
+    addChoice(composite, "Clone an existing remote repository.", "icons/wiz/repo_clone.gif", clonePage, false);
 
     RepositoryLocalPage localPage = wizard.getLocalPage();
-    addChoice(composite, "Create a new local repository.", "icons/wiz/repo_local.gif", localPage);
+    addChoice(composite, "Create a new local repository.", "icons/wiz/repo_local.gif", localPage, true);
 
     nextPage = remotePage;
     setPageComplete(true);
   }
 
-  private Button addChoice(Composite composite, String text, String imagePath, final AbstractRepositoryPage nextPage)
+  private Button addChoice(Composite composite, String text, String imagePath, final AbstractRepositoryPage nextPage,
+      boolean enabled)
   {
     this.nextPage = nextPage;
+
     Button button = new Button(composite, SWT.RADIO);
     button.setText(text);
+    button.setEnabled(enabled);
     button.addSelectionListener(new SelectionListener()
     {
       public void widgetSelected(SelectionEvent e)
@@ -97,6 +100,7 @@
 
     Label imageLabel = new Label(composite, SWT.NONE);
     imageLabel.setImage(OM.getImage(imagePath));
+    imageLabel.setEnabled(enabled);
 
     new Label(composite, SWT.NONE);
     return button;
diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/CDOExplorerUtil.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/CDOExplorerUtil.java
index bdf1a56..5752303 100644
--- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/CDOExplorerUtil.java
+++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/CDOExplorerUtil.java
@@ -92,7 +92,7 @@
     return null;
   }
 
-  private static CDOCheckout walkUp(EObject object, LinkedList<EObject> path)
+  public static CDOCheckout walkUp(EObject object, LinkedList<EObject> path)
   {
     while (object != null)
     {
diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/LocalCDORepository.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/LocalCDORepository.java
index 5bf945a..7307be6 100644
--- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/LocalCDORepository.java
+++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/LocalCDORepository.java
@@ -109,7 +109,10 @@
     versioningMode = VersioningMode.valueOf(properties.getProperty(PROP_VERSIONING_MODE));
     idGeneration = IDGeneration.valueOf(properties.getProperty(PROP_ID_GENERATION));
     tcpDisabled = Boolean.parseBoolean(properties.getProperty(PROP_TCP_DISABLED));
-    tcpPort = Integer.parseInt(properties.getProperty(PROP_TCP_PORT));
+    if (!tcpDisabled)
+    {
+      tcpPort = Integer.parseInt(properties.getProperty(PROP_TCP_PORT));
+    }
   }
 
   @Override
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/FolderCDOWorkspaceBase.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/FolderCDOWorkspaceBase.java
index 90b4e8e..987fb1f 100644
--- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/FolderCDOWorkspaceBase.java
+++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/FolderCDOWorkspaceBase.java
@@ -23,6 +23,7 @@
 import org.eclipse.emf.cdo.workspace.CDOWorkspaceBase;
 import org.eclipse.emf.cdo.workspace.CDOWorkspaceUtil;
 
+import org.eclipse.net4j.util.ObjectUtil;
 import org.eclipse.net4j.util.factory.ProductCreationException;
 import org.eclipse.net4j.util.io.ExtendedDataInputStream;
 import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
@@ -169,7 +170,7 @@
       writer.write(key);
       writer.write("\t");
       writer.write(Integer.toString(detachedVersion));
-      writer.write("\t");
+      writer.write("\n");
     }
     catch (IOException ex)
     {
@@ -315,7 +316,7 @@
       {
         for (File file : files)
         {
-          if (file.isFile())
+          if (!ObjectUtil.equals(file, addedAndDetachedFile))
           {
             CDOID id = getCDOID(file.getName());
             ids.add(id);