442326 Added ability to view file contents in Folder context

Also:
- fixed opening files in Workspace context
- changed file/folder icons in Workspace and Folder contexts
- changed double click behavior: not rename, but open file or expand folder
- added Rename button to Workspace and Folder contexts

Signed-off-by: Mixail Bobylev <mixail.bobylev@xored.com>
diff --git a/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/META-INF/MANIFEST.MF b/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/META-INF/MANIFEST.MF
index 3d551c3..315b066 100644
--- a/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/META-INF/MANIFEST.MF
+++ b/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/META-INF/MANIFEST.MF
@@ -16,6 +16,7 @@
  org.eclipse.core.variables,
  org.eclipse.rcptt.launching,
  org.eclipse.debug.core,
- org.eclipse.pde.launching
+ org.eclipse.pde.launching,
+ org.eclipse.ui.ide
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
diff --git a/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/FilesystemContextEditor.java b/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/FilesystemContextEditor.java
index a092635..52c76ef 100644
--- a/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/FilesystemContextEditor.java
+++ b/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/FilesystemContextEditor.java
@@ -13,7 +13,9 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.eclipse.core.databinding.Binding;
 import org.eclipse.core.databinding.UpdateValueStrategy;
@@ -25,6 +27,7 @@
 import org.eclipse.core.variables.VariablesPlugin;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.EList;
 import org.eclipse.emf.databinding.EMFObservables;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
@@ -34,10 +37,17 @@
 import org.eclipse.jface.fieldassist.ControlDecoration;
 import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnViewerEditor;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TextCellEditor;
 import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.TreeViewerEditor;
 import org.eclipse.jface.window.Window;
 import org.eclipse.pde.launching.IPDELauncherConstants;
 import org.eclipse.rcptt.core.model.ModelException;
@@ -46,8 +56,12 @@
 import org.eclipse.rcptt.ctx.filesystem.ui.actions.AddFiles;
 import org.eclipse.rcptt.ctx.filesystem.ui.actions.AddFolder;
 import org.eclipse.rcptt.ctx.filesystem.ui.actions.FSAction;
+import org.eclipse.rcptt.ctx.filesystem.ui.actions.OpenFile;
 import org.eclipse.rcptt.ctx.filesystem.ui.actions.Remove;
+import org.eclipse.rcptt.ctx.filesystem.ui.actions.Rename;
 import org.eclipse.rcptt.filesystem.FSCaptureParam;
+import org.eclipse.rcptt.filesystem.FSFile;
+import org.eclipse.rcptt.filesystem.FSFolder;
 import org.eclipse.rcptt.filesystem.FSResource;
 import org.eclipse.rcptt.filesystem.FilesystemContext;
 import org.eclipse.rcptt.filesystem.FilesystemFactory;
@@ -60,25 +74,20 @@
 import org.eclipse.rcptt.ui.controls.SectionWithComposite;
 import org.eclipse.rcptt.ui.editors.EditorHeader;
 import org.eclipse.rcptt.ui.launching.LaunchUtils;
+import org.eclipse.rcptt.ui.utils.DefaultTreeViewerEditStrategy;
 import org.eclipse.rcptt.ui.utils.UIContentAdapter;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyAdapter;
 import org.eclipse.swt.events.KeyEvent;
 import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.layout.RowLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.swt.widgets.Tree;
 import org.eclipse.swt.widgets.TreeItem;
@@ -168,6 +177,8 @@
 		createButton(panel, toolkit, new AddFiles());
 		createButton(panel, toolkit, new AddFolder());
 		createButton(panel, toolkit, removeAction = new Remove());
+		createButton(panel, toolkit, openFileAction = new OpenFile());
+		createButton(panel, toolkit, new Rename());
 
 		setSelection(null);
 	}
@@ -198,18 +209,14 @@
 		}
 	}
 
-	private boolean expandOrCollapse = false;
-
 	private void createTree(FormToolkit toolkit, Composite client) {
 		final Tree tree = new Tree(client, SWT.BORDER | SWT.MULTI);
-		GridDataFactory.fillDefaults().grab(true, true).span(1, 1)
-				.hint(100, 50).applyTo(tree);
-		viewer = new TreeViewer(tree);
+		GridDataFactory.fillDefaults().grab(true, true).span(1, 1).hint(100, 50).applyTo(tree);
 
+		viewer = new TreeViewer(tree);
 		viewer.setLabelProvider(new FilesystemContextLabelProvider());
 		viewer.setContentProvider(new FilesystemContextContentProvider());
 		viewer.setInput(getContextElement());
-
 		viewer.addSelectionChangedListener(new ISelectionChangedListener() {
 			public void selectionChanged(SelectionChangedEvent event) {
 				IStructuredSelection sel = (IStructuredSelection) viewer
@@ -221,67 +228,66 @@
 				setSelection(resources);
 			}
 		});
+		viewer.addDoubleClickListener(new IDoubleClickListener() {
 
-		tree.addMouseListener(new MouseAdapter() {
-			@Override
-			public void mouseUp(MouseEvent e) {
-				if (expandOrCollapse || e.button != 1) {
-					expandOrCollapse = false;
+			/**
+			 * Opens file or expands/collapses folder.
+			 */
+			public void doubleClick(DoubleClickEvent event) {
+				if (openFileAction.isEnabled()) {
+					openFileAction.run();
+				} else {
+					TreeViewer viewer = (TreeViewer) event.getViewer();
+					IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+					Object selectedNode = selection.getFirstElement();
+					viewer.setExpandedState(selectedNode, !viewer.getExpandedState(selectedNode));
+				}
+			}
+		});
+
+		// Setups renaming
+		TreeViewerEditor.create(viewer, new DefaultTreeViewerEditStrategy(viewer), ColumnViewerEditor.DEFAULT);
+		viewer.setCellEditors(new CellEditor[] { new TextCellEditor(tree) });
+		viewer.setCellModifier(new ICellModifier() {
+			public void modify(Object element, String property, Object value) {
+				TreeItem item = (TreeItem) element;
+				FSResource res = (FSResource) item.getData();
+				EObject parent = res.eContainer();
+				Set<String> allNames = getAllNames(parent);
+				allNames.remove(res.getName());
+
+				String newValue = (String) value;
+				if (allNames.contains(newValue)) {
 					return;
 				}
 
-				TreeItem item = tree.getItem(new Point(e.x, e.y));
-				if (item == null) {
-					tree.deselectAll();
-					setSelection(null);
+				if (newValue != null && !newValue.isEmpty() && !newValue.equals(res.getName())) {
+					res.setName(newValue);
 				}
 			}
-		});
 
-		tree.addKeyListener(new KeyAdapter() {
-			public void keyPressed(KeyEvent e) {
-				expandOrCollapse = false;
+			public Object getValue(Object element, String property) {
+				return ((FSResource) element).getName();
 			}
 
+			public boolean canModify(Object element, String property) {
+				return true;
+			}
+		});
+		viewer.setColumnProperties(new String[] { "" });
+
+		viewer.getControl().addKeyListener(new KeyListener() {
+
 			public void keyReleased(KeyEvent e) {
-				expandOrCollapse = false;
 			}
-		});
 
-		tree.addListener(SWT.Expand, new Listener() {
-			public void handleEvent(Event event) {
-				expandOrCollapse = true;
-			}
-		});
-
-		tree.addListener(SWT.Collapse, new Listener() {
-			public void handleEvent(Event event) {
-				expandOrCollapse = true;
-			}
-		});
-
-		tree.addKeyListener(new KeyAdapter() {
-			@Override
 			public void keyPressed(KeyEvent e) {
-				viewer.getControl().addKeyListener(new KeyListener() {
-
-					public void keyReleased(KeyEvent e) {
+				if ((SWT.DEL == e.character) && (0 == e.stateMask)) {
+					if (removeAction.isEnabled()) {
+						removeAction.run();
+						e.doit = false;
 					}
-
-					public void keyPressed(KeyEvent e) {
-						if (e.stateMask != 0)
-							return;
-
-						switch (e.keyCode) {
-						case SWT.DEL:
-							if (removeAction.isEnabled()) {
-								removeAction.run();
-								e.doit = false;
-							}
-							break;
-						}
-					}
-				});
+				}
 			}
 		});
 
@@ -492,5 +498,21 @@
 		}
 	};
 
+	private Set<String> getAllNames(EObject parent) {
+		Set<String> allNames = new HashSet<String>();
+		if (parent instanceof FSFolder) {
+			EList<FSFolder> folders = ((FSFolder) parent).getFolders();
+			EList<FSFile> files = ((FSFolder) parent).getFiles();
+			for (FSFile fsFile : files) {
+				allNames.add(fsFile.getName());
+			}
+			for (FSFolder folder : folders) {
+				allNames.add(folder.getName());
+			}
+		}
+		return allNames;
+	}
+
 	private Remove removeAction;
+	private OpenFile openFileAction;
 }
diff --git a/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/AddFiles.java b/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/AddFiles.java
index c2be25e..7efe727 100644
--- a/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/AddFiles.java
+++ b/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/AddFiles.java
@@ -19,21 +19,20 @@
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-
 import org.eclipse.rcptt.ctx.filesystem.FSUtils;
 import org.eclipse.rcptt.ctx.filesystem.ui.Activator;
 import org.eclipse.rcptt.filesystem.FSFile;
 import org.eclipse.rcptt.filesystem.FSFolder;
 import org.eclipse.rcptt.internal.ui.Images;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
 
 public class AddFiles extends FSAction {
 
 	public AddFiles() {
-		super("Add Files...", Images.getImageDescriptor(Images.FILE));
+		super("Add Files...", Images.getImageDescriptor(Images.NEW_FILE));
 	}
 
 	@Override
diff --git a/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/AddFolder.java b/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/AddFolder.java
index d3be2a3..8421c63 100644
--- a/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/AddFolder.java
+++ b/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/AddFolder.java
@@ -18,19 +18,18 @@
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-
 import org.eclipse.rcptt.ctx.filesystem.FSUtils;
 import org.eclipse.rcptt.ctx.filesystem.ui.Activator;
 import org.eclipse.rcptt.filesystem.FSFolder;
 import org.eclipse.rcptt.internal.ui.Images;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
 
 public class AddFolder extends FSAction {
 
 	public AddFolder() {
-		super("Add Folder...", Images.getImageDescriptor(Images.FOLDER));
+		super("Add Folder...", Images.getImageDescriptor(Images.NEW_FOLDER));
 	}
 
 	@Override
diff --git a/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/FSFileEditorInput.java b/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/FSFileEditorInput.java
new file mode 100644
index 0000000..5fa658f
--- /dev/null
+++ b/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/FSFileEditorInput.java
@@ -0,0 +1,105 @@
+package org.eclipse.rcptt.ctx.filesystem.ui.actions;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.rcptt.filesystem.FSFile;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.IStorageEditorInput;
+
+public class FSFileEditorInput implements IStorageEditorInput {
+	private FSFile file;
+	private String name;
+
+	public FSFileEditorInput(FSFile file, String name) {
+		this.file = file;
+		this.name = name;
+	}
+
+	public boolean exists() {
+		return true;
+	}
+
+	public ImageDescriptor getImageDescriptor() {
+		return null;
+	}
+
+	public String getName() {
+		return new Path(name).lastSegment();
+	}
+
+	public IPersistableElement getPersistable() {
+		return null;
+	}
+
+	public String getToolTipText() {
+		return name;
+	}
+
+	@SuppressWarnings("rawtypes")
+	public Object getAdapter(Class adapter) {
+		return null;
+	}
+
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((name == null) ? 0 : name.hashCode());
+		result = prime * result
+				+ ((file == null) ? 0 : file.hashCode());
+		return result;
+	}
+
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		FSFileEditorInput other = (FSFileEditorInput) obj;
+		if (name == null) {
+			if (other.name != null)
+				return false;
+		} else if (!name.equals(other.name))
+			return false;
+		if (file == null) {
+			if (other.file != null)
+				return false;
+		} else if (!file.equals(other.file))
+			return false;
+		return true;
+	}
+
+	public IStorage getStorage() throws CoreException {
+		return new IStorage() {
+
+			@SuppressWarnings("rawtypes")
+			public Object getAdapter(Class adapter) {
+				return null;
+			}
+
+			public boolean isReadOnly() {
+				return true;
+			}
+
+			public String getName() {
+				return name;
+			}
+
+			public IPath getFullPath() {
+				return new Path(name);
+			}
+
+			public InputStream getContents() throws CoreException {
+				return new ByteArrayInputStream(file.getData());
+			}
+		};
+	}
+
+}
diff --git a/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/OpenFile.java b/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/OpenFile.java
new file mode 100644
index 0000000..e8fe3d5
--- /dev/null
+++ b/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/OpenFile.java
@@ -0,0 +1,63 @@
+package org.eclipse.rcptt.ctx.filesystem.ui.actions;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.rcptt.filesystem.FSFile;
+import org.eclipse.rcptt.filesystem.FSFolder;
+import org.eclipse.rcptt.internal.ui.Images;
+import org.eclipse.rcptt.internal.ui.Q7UIPlugin;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+
+public class OpenFile extends FSAction {
+
+	public OpenFile() {
+		super("Open File", Images.getImageDescriptor(Images.FILE));
+	}
+
+	@Override
+	protected void init() {
+		setEnabled(selection != null && selection.length == 1 && selection[0] instanceof FSFile);
+	}
+
+	@Override
+	public void run() {
+		FSFile file = (FSFile) selection[0];
+		String name = getFullName(file);
+		IWorkbenchPage page = PlatformUI.getWorkbench()
+				.getActiveWorkbenchWindow().getActivePage();
+		try {
+			IDE.openEditor(page, new FSFileEditorInput(
+					file, name), "org.eclipse.ui.DefaultTextEditor");
+		} catch (PartInitException e) {
+			Q7UIPlugin.log(e);
+		}
+	}
+
+	/**
+	 * Returns file name with path through the folders.
+	 * E.g. "contents/MyProject/MyFile.txt".
+	 * 
+	 * @param file
+	 * @return
+	 */
+	private String getFullName(FSFile file) {
+		StringBuilder builder = new StringBuilder();
+		builder.append(file.getName());
+		EObject container = file.eContainer();
+		String folderName;
+		while (container != null) {
+			if (container instanceof FSFolder) {
+				folderName = ((FSFolder) container).getName();
+				if (folderName != null) {
+					builder.insert(0, folderName + "/");
+				}
+			}
+			container = container.eContainer();
+		}
+
+		return "contents/" + builder.toString();
+	}
+
+}
diff --git a/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/Rename.java b/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/Rename.java
new file mode 100644
index 0000000..db95551
--- /dev/null
+++ b/rcp/contexts/org.eclipse.rcptt.ctx.filesystem.ui/src/org/eclipse/rcptt/ctx/filesystem/ui/actions/Rename.java
@@ -0,0 +1,21 @@
+package org.eclipse.rcptt.ctx.filesystem.ui.actions;
+
+import org.eclipse.rcptt.internal.ui.Images;
+
+public class Rename extends FSAction {
+
+	public Rename() {
+		super("Rename", Images.getImageDescriptor(Images.SCENARIO_EMPTY));
+	}
+
+	@Override
+	protected void init() {
+		setEnabled(selection != null && selection.length == 1);
+	}
+
+	@Override
+	public void run() {
+		viewer.editElement(selection[0], 0);
+	}
+
+}
diff --git a/rcp/contexts/org.eclipse.rcptt.ctx.resources.ui/src/org/eclipse/rcptt/ui/resources/actions/WSAction.java b/rcp/contexts/org.eclipse.rcptt.ctx.resources.ui/src/org/eclipse/rcptt/ui/resources/actions/WSAction.java
index 91583d4..21ab2da 100644
--- a/rcp/contexts/org.eclipse.rcptt.ctx.resources.ui/src/org/eclipse/rcptt/ui/resources/actions/WSAction.java
+++ b/rcp/contexts/org.eclipse.rcptt.ctx.resources.ui/src/org/eclipse/rcptt/ui/resources/actions/WSAction.java
@@ -30,19 +30,6 @@
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.window.Window;
 import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.CheckedTreeSelectionDialog;
-import org.eclipse.ui.dialogs.ContainerSelectionDialog;
-import org.eclipse.ui.dialogs.ISelectionStatusValidator;
-import org.eclipse.ui.dialogs.ISelectionValidator;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.model.BaseWorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-
 import org.eclipse.rcptt.core.persistence.IPersistenceModel;
 import org.eclipse.rcptt.core.persistence.PersistenceManager;
 import org.eclipse.rcptt.ctx.resources.ImportUtils;
@@ -62,6 +49,18 @@
 import org.eclipse.rcptt.workspace.WSResource;
 import org.eclipse.rcptt.workspace.WorkspaceContext;
 import org.eclipse.rcptt.workspace.WorkspaceFactory;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.CheckedTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.dialogs.ISelectionValidator;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.model.BaseWorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
 
 public abstract class WSAction extends Action {
 
@@ -489,7 +488,7 @@
 	public static class OpenFile extends WSAction {
 
 		public OpenFile() {
-			super("Open File", Images.getImageDescriptor(Images.NEW_FILE));
+			super("Open File", Images.getImageDescriptor(Images.FILE));
 		}
 
 		@Override
@@ -505,21 +504,11 @@
 			if (selection[0] instanceof WSFile) {
 				WSFile file = (WSFile) selection[0];
 				String name = ImportUtils.getName(file);
-
-				// IFile iFile = storage.getFileToOpen(file);
 				IWorkbenchPage page = PlatformUI.getWorkbench()
 						.getActiveWorkbenchWindow().getActivePage();
 				try {
-					IEditorDescriptor descriptor = IDE.getEditorDescriptor(
-							name, true);
-					String id = null;
-					if (descriptor != null) {
-						id = descriptor.getId();
-					} else {
-						id = "org.eclipse.ui.TextEditor";
-					}
 					IDE.openEditor(page, new PersistenceEditorInput(
-							getContext().eResource(), name), id);
+							getContext().eResource(), name), "org.eclipse.ui.DefaultTextEditor");
 				} catch (PartInitException e) {
 					Q7UIPlugin.log(e);
 				}
@@ -536,7 +525,7 @@
 					if (descriptor != null) {
 						id = descriptor.getId();
 					} else {
-						id = "org.eclipse.ui.TextEditor";
+						id = "org.eclipse.ui.DefaultTextEditor";
 					}
 					IFile linkResource = WSUtils.getLinkResource(link);
 					if (linkResource != null) {
@@ -550,6 +539,27 @@
 
 	}
 
+	public static class Rename extends WSAction {
+
+		public Rename() {
+			super("Rename", Images.getImageDescriptor(Images.SCENARIO_EMPTY));
+		}
+
+		@Override
+		protected void init() {
+			setEnabled(selection != null
+					&& selection.length == 1
+					&& (selection[0] instanceof WSFile
+					|| selection[0] instanceof WSFolder));
+		}
+
+		@Override
+		public void run() {
+			viewer.editElement(selection[0], 0);
+		}
+
+	}
+
 	public static class AddProject extends WSAction {
 
 		public AddProject() {
diff --git a/rcp/contexts/org.eclipse.rcptt.ctx.resources.ui/src/org/eclipse/rcptt/ui/resources/viewers/WorkspaceContextEditor.java b/rcp/contexts/org.eclipse.rcptt.ctx.resources.ui/src/org/eclipse/rcptt/ui/resources/viewers/WorkspaceContextEditor.java
index 05b7e76..c1756fa 100644
--- a/rcp/contexts/org.eclipse.rcptt.ctx.resources.ui/src/org/eclipse/rcptt/ui/resources/viewers/WorkspaceContextEditor.java
+++ b/rcp/contexts/org.eclipse.rcptt.ctx.resources.ui/src/org/eclipse/rcptt/ui/resources/viewers/WorkspaceContextEditor.java
@@ -33,7 +33,9 @@
 import org.eclipse.jface.viewers.CellEditor;
 import org.eclipse.jface.viewers.ColumnViewerEditor;
 import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.ILabelDecorator;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.IStructuredSelection;
@@ -41,6 +43,32 @@
 import org.eclipse.jface.viewers.TextCellEditor;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.TreeViewerEditor;
+import org.eclipse.rcptt.core.model.IQ7NamedElement;
+import org.eclipse.rcptt.core.model.ModelException;
+import org.eclipse.rcptt.core.persistence.IPersistenceModel;
+import org.eclipse.rcptt.core.persistence.PersistenceManager;
+import org.eclipse.rcptt.core.scenario.Context;
+import org.eclipse.rcptt.core.workspace.Q7Utils;
+import org.eclipse.rcptt.ctx.resources.ImportUtils;
+import org.eclipse.rcptt.ctx.resources.WSUtils;
+import org.eclipse.rcptt.ctx.resources.WorkspaceContextImporter;
+import org.eclipse.rcptt.internal.ui.Q7UIPlugin;
+import org.eclipse.rcptt.ui.context.BaseContextEditor;
+import org.eclipse.rcptt.ui.controls.SectionWithComposite;
+import org.eclipse.rcptt.ui.editors.EditorHeader;
+import org.eclipse.rcptt.ui.resources.actions.WSAction;
+import org.eclipse.rcptt.ui.utils.DefaultTreeViewerEditStrategy;
+import org.eclipse.rcptt.ui.utils.UIContentAdapter;
+import org.eclipse.rcptt.workspace.WSContainer;
+import org.eclipse.rcptt.workspace.WSFile;
+import org.eclipse.rcptt.workspace.WSFileLink;
+import org.eclipse.rcptt.workspace.WSFolder;
+import org.eclipse.rcptt.workspace.WSProject;
+import org.eclipse.rcptt.workspace.WSProjectLink;
+import org.eclipse.rcptt.workspace.WSResource;
+import org.eclipse.rcptt.workspace.WSRoot;
+import org.eclipse.rcptt.workspace.WorkspaceContext;
+import org.eclipse.rcptt.workspace.WorkspacePackage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.KeyEvent;
 import org.eclipse.swt.events.KeyListener;
@@ -61,33 +89,6 @@
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.Section;
 
-import org.eclipse.rcptt.core.model.IQ7NamedElement;
-import org.eclipse.rcptt.core.model.ModelException;
-import org.eclipse.rcptt.core.persistence.IPersistenceModel;
-import org.eclipse.rcptt.core.persistence.PersistenceManager;
-import org.eclipse.rcptt.core.scenario.Context;
-import org.eclipse.rcptt.core.workspace.Q7Utils;
-import org.eclipse.rcptt.ctx.resources.ImportUtils;
-import org.eclipse.rcptt.ctx.resources.WSUtils;
-import org.eclipse.rcptt.ctx.resources.WorkspaceContextImporter;
-import org.eclipse.rcptt.internal.ui.Q7UIPlugin;
-import org.eclipse.rcptt.ui.context.BaseContextEditor;
-import org.eclipse.rcptt.ui.controls.SectionWithComposite;
-import org.eclipse.rcptt.ui.editors.EditorHeader;
-import org.eclipse.rcptt.ui.resources.actions.WSAction;
-import org.eclipse.rcptt.ui.utils.DoubleClickViewerEditStrategy;
-import org.eclipse.rcptt.ui.utils.UIContentAdapter;
-import org.eclipse.rcptt.workspace.WSContainer;
-import org.eclipse.rcptt.workspace.WSFile;
-import org.eclipse.rcptt.workspace.WSFileLink;
-import org.eclipse.rcptt.workspace.WSFolder;
-import org.eclipse.rcptt.workspace.WSProject;
-import org.eclipse.rcptt.workspace.WSProjectLink;
-import org.eclipse.rcptt.workspace.WSResource;
-import org.eclipse.rcptt.workspace.WSRoot;
-import org.eclipse.rcptt.workspace.WorkspaceContext;
-import org.eclipse.rcptt.workspace.WorkspacePackage;
-
 public class WorkspaceContextEditor extends BaseContextEditor {
 	private boolean corrected = false;
 	private Text ignoreByClearPattern;
@@ -260,14 +261,13 @@
 
 	private Tree createTree(Composite parent, FormToolkit toolkit) {
 		Tree tree = new Tree(parent, SWT.BORDER | SWT.MULTI);
-		GridDataFactory.fillDefaults().grab(true, true).hint(100, 50)
-				.applyTo(tree);
+		GridDataFactory.fillDefaults().grab(true, true).hint(100, 50).applyTo(tree);
+
 		viewer = new TreeViewer(tree);
-		TreeViewerEditor.create(viewer, new DoubleClickViewerEditStrategy(
-				viewer), ColumnViewerEditor.KEEP_EDITOR_ON_DOUBLE_CLICK);
+		TreeViewerEditor.create(viewer, new DefaultTreeViewerEditStrategy(
+				viewer), ColumnViewerEditor.DEFAULT);
 		viewer.setCellEditors(new CellEditor[] { new TextCellEditor(tree) });
 		viewer.setCellModifier(new ICellModifier() {
-
 			public void modify(Object element, String property, Object value) {
 				TreeItem item = (TreeItem) element;
 				WSResource res = (WSResource) item.getData();
@@ -338,17 +338,22 @@
 				setSelection(resources);
 			}
 		});
-		adapter = new UIContentAdapter() {
+		viewer.addDoubleClickListener(new IDoubleClickListener() {
 
-			protected void changed(Notification notification) {
-				if (viewer.getControl().isDisposed()) {
-					return;
+			/**
+			 * Opens file or expands/collapses folder.
+			 */
+			public void doubleClick(DoubleClickEvent event) {
+				if (openFileAction.isEnabled()) {
+					openFileAction.run();
+				} else {
+					TreeViewer viewer = (TreeViewer) event.getViewer();
+					IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+					Object selectedNode = selection.getFirstElement();
+					viewer.setExpandedState(selectedNode, !viewer.getExpandedState(selectedNode));
 				}
-				viewer.refresh();
 			}
-		};
-		getContextElement().eAdapters().add(adapter);
-
+		});
 		viewer.getControl().addKeyListener(new KeyListener() {
 
 			public void keyReleased(KeyEvent e) {
@@ -364,7 +369,19 @@
 			}
 		});
 
+		adapter = new UIContentAdapter() {
+
+			protected void changed(Notification notification) {
+				if (viewer.getControl().isDisposed()) {
+					return;
+				}
+				viewer.refresh();
+			}
+		};
+		getContextElement().eAdapters().add(adapter);
+
 		toolkit.adapt(tree);
+
 		return tree;
 	}
 
@@ -399,7 +416,8 @@
 		createButton(panel, toolkit, new WSAction.LinkFolder());
 		createButton(panel, toolkit, new WSAction.LinkFiles());
 		createButton(panel, toolkit, removeAction = new WSAction.Remove());
-		createButton(panel, toolkit, new WSAction.OpenFile());
+		createButton(panel, toolkit, openFileAction = new WSAction.OpenFile());
+		createButton(panel, toolkit, new WSAction.Rename());
 
 		// createButton(panel, new WSAction.AddFile());
 
@@ -469,5 +487,6 @@
 	private final List<Button> buttons = new ArrayList<Button>();
 
 	private WSAction.Remove removeAction;
+	private WSAction.OpenFile openFileAction;
 
 }
diff --git a/rcp/org.eclipse.rcptt.ui/src/org/eclipse/rcptt/ui/utils/DefaultTreeViewerEditStrategy.java b/rcp/org.eclipse.rcptt.ui/src/org/eclipse/rcptt/ui/utils/DefaultTreeViewerEditStrategy.java
new file mode 100644
index 0000000..bbf71f8
--- /dev/null
+++ b/rcp/org.eclipse.rcptt.ui/src/org/eclipse/rcptt/ui/utils/DefaultTreeViewerEditStrategy.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2014 Xored Software Inc 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:
+ *     Xored Software Inc - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.rcptt.ui.utils;
+
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+/**
+ * Tree/Table Viewer strategy to activate cell editing manually, not with a mouse.
+ */
+public class DefaultTreeViewerEditStrategy extends ColumnViewerEditorActivationStrategy {
+
+	public DefaultTreeViewerEditStrategy(ColumnViewer viewer) {
+		super(viewer);
+	}
+
+	/**
+	 * @param event
+	 *            the event triggering the action
+	 * @return <code>true</code> if this event should open the editor
+	 */
+	protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
+		boolean singleSelect = ((IStructuredSelection) getViewer().getSelection()).size() == 1;
+
+		return singleSelect
+				&& (event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC || event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL);
+	}
+
+}
diff --git a/rcp/org.eclipse.rcptt.ui/src/org/eclipse/rcptt/ui/utils/DoubleClickViewerEditStrategy.java b/rcp/org.eclipse.rcptt.ui/src/org/eclipse/rcptt/ui/utils/DoubleClickViewerEditStrategy.java
deleted file mode 100644
index e0aff80..0000000
--- a/rcp/org.eclipse.rcptt.ui/src/org/eclipse/rcptt/ui/utils/DoubleClickViewerEditStrategy.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2014 Xored Software Inc 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:
- *     Xored Software Inc - initial API and implementation and/or initial documentation
- *******************************************************************************/
-package org.eclipse.rcptt.ui.utils;
-
-import org.eclipse.jface.viewers.ColumnViewer;
-import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
-import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.events.MouseEvent;
-
-/**
- * Tree/Table Viewer strategy to activate cell editing on double click 
- */
-public class DoubleClickViewerEditStrategy extends
-		ColumnViewerEditorActivationStrategy {
-
-	public DoubleClickViewerEditStrategy(ColumnViewer viewer) {
-		super(viewer);
-	}
-
-	/**
-	 * @param event
-	 *            the event triggering the action
-	 * @return <code>true</code> if this event should open the editor
-	 */
-	protected boolean isEditorActivationEvent(
-			ColumnViewerEditorActivationEvent event) {
-		boolean singleSelect = ((IStructuredSelection) getViewer()
-				.getSelection()).size() == 1;
-		boolean isLeftMouseSelect = event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
-				&& ((MouseEvent) event.sourceEvent).button == 1;
-
-		return singleSelect
-				&& (isLeftMouseSelect
-						|| event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC || event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL);
-	}
-
-}
diff --git a/rcpttTests/platform_tests/Editing/Context/Folder Context/Content/ExpandCollapse.test b/rcpttTests/platform_tests/Editing/Context/Folder Context/Content/ExpandCollapse.test
new file mode 100644
index 0000000..9ac57e9
--- /dev/null
+++ b/rcpttTests/platform_tests/Editing/Context/Folder Context/Content/ExpandCollapse.test
@@ -0,0 +1,51 @@
+--- RCPTT testcase ---
+Format-Version: 1.0
+Contexts: _ymiyse5IEeCU6db9MgIBkA,_CvfmAGniEeK1ouDBqHdAhQ
+Element-Name: ExpandCollapse
+Element-Type: testcase
+Element-Version: 3.0
+External-Reference: 
+Id: _OOoIEDfZEeSwKtKur3isuQ
+Runtime-Version: 1.5.0.201406020630
+Save-Time: 9/9/14 12:04 PM
+Testcase-Type: ecl
+
+------=_.description-216f885c-d591-38ce-8ea2-e4f8cb4d6ffa
+Content-Type: text/plain
+Entry-Name: .description
+
+Copyright (c) 2009, 2014 Xored Software Inc 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:
+    Xored Software Inc - initial creation and/or initial documentation
+--------------------------------------------------------------------------------
+
+TEST STEPS
+
+1. Open context;
+2. Double click on folder;
+3. Make sure that folder is expanded;
+4. Double click on folder;
+5. Make sure that folder is collapsed.
+------=_.description-216f885c-d591-38ce-8ea2-e4f8cb4d6ffa--
+------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac
+Content-Type: text/ecl
+Entry-Name: .content
+
+with [get-view "Test Explorer" | get-tree] {
+    select project | double-click
+    select "project/FilledFolderContext" | double-click
+}
+
+get-editor FilledFolderContext | get-section Folder | get-tree | select toFolderContext | double-click
+get-editor FilledFolderContext | get-section Folder | get-tree | get-item toFolderContext 
+    | get-property "getExpanded()" | equals true | verify-true
+    
+get-editor FilledFolderContext | get-section Folder | get-tree | select toFolderContext | double-click
+get-editor FilledFolderContext | get-section Folder | get-tree | get-item toFolderContext 
+    | get-property "getExpanded()" | equals true | verify-false    
+------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac--
diff --git a/rcpttTests/platform_tests/Editing/Context/Folder Context/Content/OpenFiles.test b/rcpttTests/platform_tests/Editing/Context/Folder Context/Content/OpenFiles.test
new file mode 100644
index 0000000..b151c60
--- /dev/null
+++ b/rcpttTests/platform_tests/Editing/Context/Folder Context/Content/OpenFiles.test
@@ -0,0 +1,57 @@
+--- RCPTT testcase ---
+Format-Version: 1.0
+Contexts: _ymiyse5IEeCU6db9MgIBkA,_CvfmAGniEeK1ouDBqHdAhQ
+Element-Name: OpenFiles
+Element-Type: testcase
+Element-Version: 3.0
+External-Reference: 
+Id: _hezQ4DfcEeSklYMSc-h2gA
+Runtime-Version: 1.5.0.201406020630
+Save-Time: 9/9/14 11:51 AM
+Testcase-Type: ecl
+
+------=_.description-216f885c-d591-38ce-8ea2-e4f8cb4d6ffa
+Content-Type: text/plain
+Entry-Name: .description
+
+Copyright (c) 2009, 2014 Xored Software Inc 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:
+    Xored Software Inc - initial creation and/or initial documentation
+--------------------------------------------------------------------------------
+
+TEST STEPS
+
+1. Open context;
+2. Double click on file;
+3. Make sure that file is opened and has expected content;
+4. Open another file via button "Open File";
+5. Make sure that file is opened and has expected content.
+------=_.description-216f885c-d591-38ce-8ea2-e4f8cb4d6ffa--
+------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac
+Content-Type: text/ecl
+Entry-Name: .content
+
+with [get-view "Test Explorer" | get-tree] {
+    select project | double-click
+    select "project/FilledFolderContext" | double-click
+}
+with [get-editor FilledFolderContext | get-section Folder | get-tree] {
+    select toFolderContext | double-click
+    select "toFolderContext/TestFolder" | double-click
+    select "toFolderContext/TestFolder/new_test.txt" | double-click
+}
+get-editor "new_test.txt" | get-text-viewer | get-property "getText()" | equals "file with test line" | verify-true
+with [get-editor FilledFolderContext] {
+    click
+    with [get-section Folder] {
+        get-tree | select "toFolderContext/test.png"
+        get-button "Open File" | click
+    }
+}
+get-editor "test.png" | get-text-viewer | get-property "getText()" | contains "PNG" | verify-true
+------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac--
diff --git a/rcpttTests/platform_tests/Editing/Context/Folder Context/Content/Rename.test b/rcpttTests/platform_tests/Editing/Context/Folder Context/Content/Rename.test
new file mode 100644
index 0000000..58f6108
--- /dev/null
+++ b/rcpttTests/platform_tests/Editing/Context/Folder Context/Content/Rename.test
@@ -0,0 +1,86 @@
+--- RCPTT testcase ---
+Format-Version: 1.0
+Contexts: _ymiyse5IEeCU6db9MgIBkA,_CvfmAGniEeK1ouDBqHdAhQ
+Element-Name: Rename
+Element-Type: testcase
+Element-Version: 3.0
+External-Reference: 
+Id: _CcpK8DfdEeSklYMSc-h2gA
+Runtime-Version: 1.5.0.201406020630
+Save-Time: 9/9/14 11:55 AM
+Testcase-Type: ecl
+
+------=_.description-216f885c-d591-38ce-8ea2-e4f8cb4d6ffa
+Content-Type: text/plain
+Entry-Name: .description
+
+Copyright (c) 2009, 2014 Xored Software Inc 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:
+    Xored Software Inc - initial creation and/or initial documentation
+--------------------------------------------------------------------------------
+
+TEST STEPS
+
+1. Open context;
+2. Rename file and folder;
+3. Make sure that items have new names;
+4. Close context and open again;
+5. Make sure that items have new names.
+------=_.description-216f885c-d591-38ce-8ea2-e4f8cb4d6ffa--
+------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac
+Content-Type: text/ecl
+Entry-Name: .content
+
+with [get-view "Test Explorer" | get-tree] {
+    select project | double-click
+    select "project/FilledFolderContext" | double-click
+}
+with [get-editor FilledFolderContext | get-section Folder] {
+    with [get-tree] {
+        select toCapture | double-click
+        select "toCapture/file.txt"
+    }
+    get-button Rename | click
+    with [get-tree] {
+        select "toCapture/file.txt" | activate-cell-edit
+        with [get-editbox] {
+            set-text "file.txt_renamed"
+            key-type Enter
+        }
+        apply-cell-edit -deactivate
+        select toCapture
+    }
+    get-button Rename | click
+    with [get-tree] {
+        select toCapture | activate-cell-edit
+        with [get-editbox] {
+            set-text "toCapture_renamed"
+            key-type Enter
+        }
+        apply-cell-edit -deactivate
+    }
+}
+with [get-editor FilledFolderContext | get-section Folder | get-tree] {
+    get-item "toCapture_renamed" | get-property "getText()" | equals "toCapture_renamed" | verify-true
+    get-item "toCapture_renamed/file.txt_renamed" | get-property "getText()" | equals "file.txt_renamed" | verify-true
+}
+
+with [get-editor FilledFolderContext] {
+    get-section Folder | get-tree | key-type "M1+s"
+    close
+}
+with [get-view "Test Explorer"] {
+    click
+    get-tree | select "project/FilledFolderContext" | double-click
+}
+with [get-editor FilledFolderContext | get-section Folder | get-tree] {
+    get-item "toCapture_renamed" | get-property "getText()" | equals "toCapture_renamed" | verify-true
+    get-item "toCapture_renamed/file.txt_renamed" | get-property "getText()" | equals "file.txt_renamed" | verify-true
+}
+
+------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac--
diff --git a/rcpttTests/platform_tests/Editing/Context/Workspace Context/Content/ExpandCollapse.test b/rcpttTests/platform_tests/Editing/Context/Workspace Context/Content/ExpandCollapse.test
new file mode 100644
index 0000000..da9bdeb
--- /dev/null
+++ b/rcpttTests/platform_tests/Editing/Context/Workspace Context/Content/ExpandCollapse.test
@@ -0,0 +1,50 @@
+--- RCPTT testcase ---
+Format-Version: 1.0
+Contexts: _ymiyse5IEeCU6db9MgIBkA,_E1k1UP2pEeKZNomN8DrgVg
+Element-Name: ExpandCollapse
+Element-Type: testcase
+Element-Version: 3.0
+External-Reference: 
+Id: _HSbSUDfWEeSwKtKur3isuQ
+Runtime-Version: 1.5.0.201406020630
+Save-Time: 9/9/14 11:07 AM
+Testcase-Type: ecl
+
+------=_.description-216f885c-d591-38ce-8ea2-e4f8cb4d6ffa
+Content-Type: text/plain
+Entry-Name: .description
+
+Copyright (c) 2009, 2014 Xored Software Inc 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:
+    Xored Software Inc - initial creation and/or initial documentation
+--------------------------------------------------------------------------------
+
+TEST STEPS
+
+1. Open context;
+2. Double click on folder;
+3. Make sure that folder is expanded;
+4. Double click on folder;
+5. Make sure that folder is collapsed.
+------=_.description-216f885c-d591-38ce-8ea2-e4f8cb4d6ffa--
+------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac
+Content-Type: text/ecl
+Entry-Name: .content
+
+with [get-view "Test Explorer" | get-tree] {
+    select MyProject | double-click
+    select "MyProject/WS Context" | double-click
+}
+get-editor "WS Context" | get-section Workspace | get-tree | select MyProject | double-click
+get-editor "WS Context" | get-section Workspace | get-tree | get-item MyProject | get-property "getExpanded()" 
+    | equals true | verify-true
+get-editor "WS Context" | get-section Workspace | get-tree | select MyProject | double-click
+get-editor "WS Context" | get-section Workspace | get-tree | get-item MyProject | get-property "getExpanded()" 
+    | equals true | verify-false
+
+------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac--
diff --git a/rcpttTests/platform_tests/Editing/Context/Workspace Context/Content/OpenFiles.test b/rcpttTests/platform_tests/Editing/Context/Workspace Context/Content/OpenFiles.test
new file mode 100644
index 0000000..2262ba3
--- /dev/null
+++ b/rcpttTests/platform_tests/Editing/Context/Workspace Context/Content/OpenFiles.test
@@ -0,0 +1,56 @@
+--- RCPTT testcase ---
+Format-Version: 1.0
+Contexts: _ymiyse5IEeCU6db9MgIBkA,_E1k1UP2pEeKZNomN8DrgVg
+Element-Name: OpenFiles
+Element-Type: testcase
+Element-Version: 3.0
+External-Reference: 
+Id: _4AT9sDfWEeSwKtKur3isuQ
+Runtime-Version: 1.5.0.201406020630
+Save-Time: 9/9/14 11:16 AM
+Testcase-Type: ecl
+
+------=_.description-216f885c-d591-38ce-8ea2-e4f8cb4d6ffa
+Content-Type: text/plain
+Entry-Name: .description
+
+Copyright (c) 2009, 2014 Xored Software Inc 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:
+    Xored Software Inc - initial creation and/or initial documentation
+--------------------------------------------------------------------------------
+
+TEST STEPS
+
+1. Open context;
+2. Double click on file;
+3. Make sure that file is opened and has expected content;
+4. Open another file via button "Open File";
+5. Make sure that file is opened and has expected content.
+------=_.description-216f885c-d591-38ce-8ea2-e4f8cb4d6ffa--
+------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac
+Content-Type: text/ecl
+Entry-Name: .content
+
+with [get-view "Test Explorer" | get-tree] {
+    select MyProject | double-click
+    select "MyProject/WS Context" | double-click
+}
+with [get-editor "WS Context" | get-section Workspace | get-tree] {
+    select MyProject | double-click
+    select "MyProject/.project" | double-click
+}
+get-editor ".project" | get-text-viewer | get-property text | contains "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | verify-true
+with [get-editor "WS Context"] {
+    click
+    with [get-section Workspace] {
+        get-tree | select "MyProject/WB Context.ctx"
+        get-button "Open File" | click
+    }
+}
+get-editor "WB Context.ctx" | get-text-viewer | get-property text | contains "Context-Type: com.xored.q7.ui.context.workbench" | verify-true
+------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac--
diff --git a/rcpttTests/platform_tests/Editing/Context/Workspace Context/Content/Rename.test b/rcpttTests/platform_tests/Editing/Context/Workspace Context/Content/Rename.test
new file mode 100644
index 0000000..71eeedb
--- /dev/null
+++ b/rcpttTests/platform_tests/Editing/Context/Workspace Context/Content/Rename.test
@@ -0,0 +1,87 @@
+--- RCPTT testcase ---
+Format-Version: 1.0
+Contexts: _ymiyse5IEeCU6db9MgIBkA,_E1k1UP2pEeKZNomN8DrgVg
+Element-Name: Rename
+Element-Type: testcase
+Element-Version: 3.0
+External-Reference: 
+Id: _GbUZQDfYEeSwKtKur3isuQ
+Runtime-Version: 1.5.0.201406020630
+Save-Time: 9/9/14 11:53 AM
+Testcase-Type: ecl
+
+------=_.description-216f885c-d591-38ce-8ea2-e4f8cb4d6ffa
+Content-Type: text/plain
+Entry-Name: .description
+
+Copyright (c) 2009, 2014 Xored Software Inc 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:
+    Xored Software Inc - initial creation and/or initial documentation
+--------------------------------------------------------------------------------
+
+TEST STEPS
+
+1. Open context;
+2. Rename file and folder;
+3. Make sure that items have new names;
+4. Close context and open again;
+5. Make sure that items have new names.
+------=_.description-216f885c-d591-38ce-8ea2-e4f8cb4d6ffa--
+------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac
+Content-Type: text/ecl
+Entry-Name: .content
+
+with [get-view "Test Explorer" | get-tree] {
+    select MyProject | double-click
+    select "MyProject/WS Context" | double-click
+}
+with [get-editor "WS Context" | get-section Workspace] {
+    with [get-tree] {
+        select MyProject | double-click
+        select "MyProject/.project"
+    }
+    get-button Rename | click
+    with [get-tree] {
+        select "MyProject/.project" | activate-cell-edit
+        with [get-editbox] {
+            key-type Right
+            set-text ".project_renamed"
+            key-type Enter
+        }
+        apply-cell-edit -deactivate
+        select MyProject
+    }
+    get-button Rename | click
+    with [get-tree] {
+        select MyProject | activate-cell-edit
+        with [get-editbox] {
+            set-text "MyProject_renamed"
+            key-type Enter
+        }
+        apply-cell-edit -deactivate
+    }
+}
+with [get-editor "WS Context" | get-section Workspace | get-tree] {
+    get-item "MyProject_renamed" | get-property "getText()" | equals "MyProject_renamed" | verify-true
+    get-item "MyProject_renamed/.project_renamed" | get-property "getText()" | equals ".project_renamed" | verify-true
+}
+
+with [get-editor "WS Context"] {
+    get-section Workspace | get-tree | key-type "M1+s"
+    close
+}
+with [get-view "Test Explorer"] {
+    click
+    get-tree | select "MyProject/WS Context" | double-click
+}
+with [get-editor "WS Context" | get-section Workspace | get-tree] {
+    get-item "MyProject_renamed" | get-property "getText()" | equals "MyProject_renamed" | verify-true
+    get-item "MyProject_renamed/.project_renamed" | get-property "getText()" | equals ".project_renamed" | verify-true
+}
+
+------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac--