Skip to content

Workspace

Overview

Module

IDE workspace operations — list, create, and delete the per-user workspaces that the IDE Projects perspective shows, and read or replace the content of files inside them. Unlike the JSON-string accessors elsewhere in the platform, this facade returns the platform's own Workspace and File domain types directly (org.eclipse.dirigible.components.ide.workspace.domain.Workspace / ...domain.File) — the same objects the IDE renders, so the workspace tree stays consistent across UI and programmatic edits.

Use this from build / migration scripts and from IDE extensions that need to prepare or fix up a user's workspace. For published artefacts use Registry (read-only) or Repository (mutable); for filesystem paths outside the registry use org.eclipse.dirigible.sdk.io.Files.

Key Features

  • Direct domain objects: Returns platform Workspace and File types rather than JSON strings.
  • CRUD on workspaces: Create, fetch by name, list, and delete.
  • File content access: Read byte[] content; write text or byte[].
  • IDE consistency: Operations are visible to the running IDE without extra synchronization.

Example Usage

java
import org.eclipse.dirigible.components.ide.workspace.domain.File;
import org.eclipse.dirigible.components.ide.workspace.domain.Workspace;
import org.eclipse.dirigible.sdk.platform.Workspace;

// Create a workspace for the current user (if missing) and grab the existing one:
Workspace ws = Workspace.createWorkspace("workspace");
Workspace existing = Workspace.getWorkspace("workspace");

// Walk down to a file and replace its content:
File file = existing.getProject("demo").getFile("README.md");
Workspace.setContent(file, "# Demo\n\nHello, world.\n");

// Read it back as bytes:
byte[] bytes = Workspace.getContent(file);

Methods

createWorkspace()

Creates a new IDE workspace with the given name and returns its domain object.

java
public static org.eclipse.dirigible.components.ide.workspace.domain.Workspace createWorkspace(String name);
ParameterTypeDescription
nameStringThe workspace name.

Returns

  • Type: org.eclipse.dirigible.components.ide.workspace.domain.Workspace
  • Description: The created (or existing) workspace.

getWorkspace()

Returns the domain object for an existing workspace.

java
public static org.eclipse.dirigible.components.ide.workspace.domain.Workspace getWorkspace(String name);
ParameterTypeDescription
nameStringThe workspace name.

Returns

  • Type: org.eclipse.dirigible.components.ide.workspace.domain.Workspace
  • Description: The workspace, or a wrapper that reports it doesn't exist.

listWorkspaces()

Returns the names of all workspaces visible to the current user.

java
public static String listWorkspaces();

Returns

  • Type: String
  • Description: A JSON-serialized list of workspace names.

deleteWorkspace()

Removes the named workspace.

java
public static void deleteWorkspace(String name);
ParameterTypeDescription
nameStringThe workspace name.

Returns

  • Type: void

getContent()

Returns the raw bytes of the given workspace file.

java
public static byte[] getContent(File file);
ParameterTypeDescription
fileFileThe workspace file domain object.

Returns

  • Type: byte[]
  • Description: The file's raw bytes.

setContent()

Replaces the content of a workspace file with the given text.

java
public static void setContent(File file, String input);
ParameterTypeDescription
fileFileThe workspace file domain object.
inputStringThe new text content.

Returns

  • Type: void

setContent()

Replaces the content of a workspace file with the given raw bytes.

java
public static void setContent(File file, byte[] input);
ParameterTypeDescription
fileFileThe workspace file domain object.
inputbyte[]The new raw bytes.

Returns

  • Type: void

Released under the EPL-2.0 License.