POC working on Win 11
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="lib/ipcsocket-1.4.0.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jna-5.8.0.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jna-platform-5.8.0.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src/"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
@@ -3,5 +3,3 @@
|
||||
/lib/
|
||||
.DS_Store
|
||||
/**/.DS_Store
|
||||
.project
|
||||
.classpath
|
||||
@@ -4,7 +4,7 @@ Bundle-Name: org.springframework.ide.eclipse.xterm
|
||||
Bundle-SymbolicName: org.springframework.ide.eclipse.xterm;singleton:=true
|
||||
Bundle-Version: 4.16.0.qualifier
|
||||
Automatic-Module-Name: org.springframework.ide.eclipse.xterm
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Bundle-Activator: org.springframework.ide.eclipse.xterm.XtermPlugin
|
||||
Require-Bundle: org.eclipse.ui;bundle-version="3.115.0",
|
||||
org.eclipse.core.runtime,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<extension
|
||||
point="org.eclipse.ui.views">
|
||||
<view
|
||||
allowMultiple="true"
|
||||
category="org.eclipse.ui"
|
||||
class="org.springframework.ide.eclipse.xterm.views.TerminalView"
|
||||
icon="icons/terminal.png"
|
||||
@@ -12,6 +13,7 @@
|
||||
name="Xterm">
|
||||
</view>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.e4.ui.css.swt.theme">
|
||||
<stylesheet
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<artifactId>org.springframework.ide.eclipse.xterm</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.scala-sbt.ipcsocket</groupId>
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.springframework.ide.eclipse.chromium.browser;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -57,10 +58,10 @@ public class ElectronBrowserCanvas extends Canvas
|
||||
private Image createImage(int width, int height)
|
||||
{
|
||||
ImageData data = new ImageData(width, height, 32, new PaletteData(0xff0000,0x00ff00, 0x0000ff));
|
||||
data.setAlpha(0, 0, 0);
|
||||
Arrays.fill(data.alphaData, (byte) -1);
|
||||
Arrays.fill(data.data, (byte) -1);
|
||||
return new Image(null, data);
|
||||
// data.setAlpha(0, 0, 0);
|
||||
// Arrays.fill(data.alphaData, (byte) -1);
|
||||
// Arrays.fill(data.data, (byte) -1);
|
||||
return new Image(getDisplay(), data);
|
||||
}
|
||||
|
||||
public ElectronBrowserCanvas(Composite parent)
|
||||
@@ -564,8 +565,9 @@ public class ElectronBrowserCanvas extends Canvas
|
||||
try
|
||||
{
|
||||
// TODO add Linux and Mac
|
||||
unzip(getClass().getResourceAsStream("/headless-electron-darwin-x64-0.0.1.zip"), tempDir);
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(tempDir + File.separator + "headless-electron.app/Contents/MacOS/headless-electron");
|
||||
// unzip(getClass().getResourceAsStream("/headless-electron-darwin-x64-0.0.1.zip"), tempDir);
|
||||
unzip(new FileInputStream(new File(System.getProperty("user.home") + "/headless-electron-win32-x64-0.0.1.zip")), tempDir);
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(tempDir + File.separator + "headless-electron.exe");
|
||||
process = processBuilder.start();
|
||||
}
|
||||
catch (IOException e1)
|
||||
|
||||
@@ -21,19 +21,14 @@ import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.action.IToolBarManager;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.layout.GridDataFactory;
|
||||
import org.eclipse.jface.layout.GridLayoutFactory;
|
||||
import org.eclipse.jface.resource.ColorRegistry;
|
||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.graphics.RGBA;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.IActionBars;
|
||||
import org.eclipse.ui.IMemento;
|
||||
import org.eclipse.ui.IViewSite;
|
||||
@@ -64,7 +59,6 @@ public class TerminalView extends ViewPart {
|
||||
private Action refreshAction;
|
||||
|
||||
private ElectronBrowserCanvas browser;
|
||||
private Text addressBar;
|
||||
|
||||
private String terminalId = DEFAULT_TERMINAL_ID;
|
||||
|
||||
@@ -74,8 +68,6 @@ public class TerminalView extends ViewPart {
|
||||
|
||||
private boolean isNewView;
|
||||
|
||||
private Composite parent;
|
||||
|
||||
private final IPropertyChangeListener PROPERTY_LISTENER = new IPropertyChangeListener() {
|
||||
|
||||
@Override
|
||||
@@ -97,41 +89,10 @@ public class TerminalView extends ViewPart {
|
||||
|
||||
@Override
|
||||
public void createPartControl(Composite parent) {
|
||||
this.parent = parent;
|
||||
PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(PROPERTY_LISTENER);
|
||||
|
||||
Composite shell = new Composite(parent, SWT.None);
|
||||
GridLayout layout = new GridLayout(1, false);
|
||||
layout.marginHeight = 0;
|
||||
layout.marginWidth = 0;
|
||||
shell.setLayout(layout);
|
||||
|
||||
|
||||
String url = "https://google.com";
|
||||
addressBar = new Text(shell, SWT.SINGLE);
|
||||
addressBar.setText(url);
|
||||
GridData layoutData1 = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||
addressBar.setLayoutData(layoutData1);
|
||||
|
||||
browser = new ElectronBrowserCanvas(shell, false);
|
||||
GridData layoutData2 = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
browser.setLayoutData(layoutData2);
|
||||
|
||||
addressBar.addListener(SWT.Traverse, event -> {
|
||||
if (event.detail == SWT.TRAVERSE_RETURN)
|
||||
{
|
||||
String text = addressBar.getText();
|
||||
if (!text.startsWith("http") && !text.isEmpty())
|
||||
{
|
||||
text = "http://" + text;
|
||||
addressBar.setText(text);
|
||||
}
|
||||
browser.browse(text);
|
||||
}
|
||||
});
|
||||
|
||||
// browser = new ElectronBrowserCanvas(parent, false);
|
||||
// browser.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
|
||||
browser = new ElectronBrowserCanvas(parent, true);
|
||||
browser.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
|
||||
makeActions();
|
||||
contributeToActionBars();
|
||||
if (isNewView) {
|
||||
@@ -142,6 +103,7 @@ public class TerminalView extends ViewPart {
|
||||
} else {
|
||||
navigateToTerminal(terminalId, cmd, cwd == null ? ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString() : cwd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean isDefault() {
|
||||
@@ -189,7 +151,6 @@ public class TerminalView extends ViewPart {
|
||||
if (Display.getCurrent() != null) {
|
||||
if (browser != null && !browser.isDisposed() && terminalId.equals(TerminalView.this.terminalId)) {
|
||||
String url = createUrl(serviceUrl, terminalId, cmd, cwd);
|
||||
addressBar.setText(url);
|
||||
XtermPlugin.getDefault().getLog().info("Navigating to " + url);
|
||||
browser.browse(url);
|
||||
}
|
||||
@@ -199,7 +160,6 @@ public class TerminalView extends ViewPart {
|
||||
display.asyncExec(() -> {
|
||||
if (browser != null && !browser.isDisposed() && terminalId.equals(TerminalView.this.terminalId)) {
|
||||
String url = createUrl(serviceUrl, terminalId, cmd, cwd);
|
||||
addressBar.setText(url);
|
||||
XtermPlugin.getDefault().getLog().info("Navigating to " + url);
|
||||
browser.browse(url);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user