Skip to content

Commit 910b6fc

Browse files
amartya4256HeikoKlare
authored andcommitted
Set Edge data directory to workspace on Windows
This contributes to adding the workspace address to the display data on workbench initialization as the data directory used by Edge browser. Contributes to eclipse-platform/eclipse.platform.swt#1013
1 parent 857f51a commit 910b6fc

File tree

1 file changed

+22
-0
lines changed
  • bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal

1 file changed

+22
-0
lines changed

bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import java.net.URI;
3838
import java.net.URISyntaxException;
3939
import java.net.URL;
40+
import java.nio.file.Paths;
4041
import java.util.ArrayList;
4142
import java.util.Arrays;
4243
import java.util.Collection;
@@ -74,6 +75,7 @@
7475
import org.eclipse.core.runtime.ListenerList;
7576
import org.eclipse.core.runtime.MultiStatus;
7677
import org.eclipse.core.runtime.Platform;
78+
import org.eclipse.core.runtime.Platform.OS;
7779
import org.eclipse.core.runtime.SafeRunner;
7880
import org.eclipse.core.runtime.Status;
7981
import org.eclipse.core.runtime.SubMonitor;
@@ -140,6 +142,7 @@
140142
import org.eclipse.jface.window.IShellProvider;
141143
import org.eclipse.jface.window.Window;
142144
import org.eclipse.osgi.internal.location.LocationHelper;
145+
import org.eclipse.osgi.service.datalocation.Location;
143146
import org.eclipse.osgi.service.runnable.StartupMonitor;
144147
import org.eclipse.osgi.util.NLS;
145148
import org.eclipse.swt.SWT;
@@ -292,6 +295,8 @@ public final class Workbench extends EventManager implements IWorkbench, org.ecl
292295
public static final String PROP_EXIT_CODE = "eclipse.exitcode"; //$NON-NLS-1$
293296
private static final String CMD_DATA = "-data"; //$NON-NLS-1$
294297

298+
private static final String EDGE_USER_DATA_FOLDER = "org.eclipse.swt.internal.win32.Edge.userDataFolder"; //$NON-NLS-1$
299+
295300
private static final class StartupProgressBundleListener implements ServiceListener {
296301

297302
private final SubMonitor subMonitor;
@@ -451,6 +456,10 @@ public void serviceChanged(ServiceEvent event) {
451456
private Workbench(Display display, final WorkbenchAdvisor advisor, MApplication app, IEclipseContext appContext) {
452457
this.advisor = Objects.requireNonNull(advisor);
453458
this.display = Objects.requireNonNull(display);
459+
if (OS.isWindows()) {
460+
setEdgeDataDirectory(this.display);
461+
}
462+
454463
application = app;
455464
e4Context = appContext;
456465

@@ -510,6 +519,19 @@ public void eventLoopException(Throwable exception) {
510519
new WorkbenchLocationService(IServiceScopes.WORKBENCH_SCOPE, this, null, null, null, null, 0));
511520
}
512521

522+
private static void setEdgeDataDirectory(Display display) {
523+
Location workspaceLocation = Platform.getInstanceLocation();
524+
if (workspaceLocation == null) {
525+
return;
526+
}
527+
try {
528+
URI workspaceLocationURI = workspaceLocation.getURL().toURI();
529+
display.setData(EDGE_USER_DATA_FOLDER, Paths.get(workspaceLocationURI).toString());
530+
} catch (URISyntaxException e) {
531+
WorkbenchPlugin.log("Invalid workspace location to be set for Edge browser.", e); //$NON-NLS-1$
532+
}
533+
}
534+
513535
/**
514536
* Returns the one and only instance of the workbench, if there is one.
515537
*

0 commit comments

Comments
 (0)