Package org.eclipse.ui.internal
Class WorkspaceLock
java.lang.Object
org.eclipse.ui.internal.WorkspaceLock
Utility class for reading and presenting workspace lock information.
This class is used during two different phases of the Eclipse application lifecycle:
- before the Workbench is created (no workbench windows exist, such as when the Workspace Launcher dialog is displayed)
- after the Workbench has been created and workbench windows are available
To support both environments, this class does not rely on workbench-specific
APIs such as PlatformUI.getWorkbench() or IWorkbenchWindow,
nor on any API that requires an initialized workbench window. Only SWT-level
constructs (for example, Display and
Shell) and core/runtime APIs are used.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PathgetLockFile(URL workspaceUrl) Returns the workspace lock file for given workspace URL (the file which is actually locked if an Eclipse application is using this workspace).static PathgetLockInfoFile(URL workspaceUrl) Returns the lock info file (the file where information about last workspace lock owner is saved).static StringgetWorkspaceLockDetails(URL workspaceUrl) Read workspace lock file of the selected workspace if it is locked by another Eclipse application and parse all the properties present.static booleanisWorkspaceLocked(URL workspaceUrl) Checks if the given workspace path is locked by another Eclipse instance.static voidshowWorkspaceLockedDialog(Shell shell, String workspacePath, String workspaceLockOwner) Opens an error dialog indicating that the selected workspace is locked by another Eclipse instance.
-
Field Details
-
PROCESS_ID
- See Also:
-
DISPLAY
- See Also:
-
HOST
- See Also:
-
USER
- See Also:
-
-
Constructor Details
-
WorkspaceLock
public WorkspaceLock()
-
-
Method Details
-
getWorkspaceLockDetails
Read workspace lock file of the selected workspace if it is locked by another Eclipse application and parse all the properties present. Based on the Eclipse version and operating system some or all the properties may be not present. In such scenario empty string may be returned.- Parameters:
workspaceUrl- theURLof workspace to check for lock details- Returns:
nullif workspace is not locked, empty string if workspace is locked but no details are available (or lock file is not accessible), or a formatted string with lock details
-
getLockInfoFile
Returns the lock info file (the file where information about last workspace lock owner is saved).- Parameters:
workspaceUrl- theURLof selected workspace- Returns:
- the path to the
.lock_infofile within the specified workspace, ornullif the workspace URL cannot be converted to a valid URI
-
getLockFile
Returns the workspace lock file for given workspace URL (the file which is actually locked if an Eclipse application is using this workspace).- Parameters:
workspaceUrl- theURLof selected workspace- Returns:
- the path to the
.lockfile within the specified workspace, ornullif the workspace URL cannot be converted to a valid URI
-
showWorkspaceLockedDialog
public static void showWorkspaceLockedDialog(Shell shell, String workspacePath, String workspaceLockOwner) Opens an error dialog indicating that the selected workspace is locked by another Eclipse instance.This method works in both early startup (before the Workbench is created) and in normal runtime (after Workbench windows exist).
- Parameters:
shell- the parentShellfor the dialog, ornullif no workbench window is availableworkspacePath- the absolute path of the workspace that could not be lockedworkspaceLockOwner- a formatted description of the existing lock owner
-
isWorkspaceLocked
Checks if the given workspace path is locked by another Eclipse instance.- Parameters:
workspaceUrl- theURLof workspace to check for lock- Returns:
trueif the workspace is locked,falseotherwise
-