From e33a921641d4bd5293be6c8fdbebd8ccecc690f4 Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Thu, 15 Oct 2020 17:30:35 -0400 Subject: [PATCH] Xterm view for OS terminal in Eclipse --- eclipse-distribution/pom.xml | 16 +- .../.gitignore | 6 + .../META-INF/MANIFEST.MF | 13 + .../build.properties | 5 + .../plugin.xml | 11 + .../pom.xml | 69 ++++ .../boot/dash/xterm/BootDashInjections.java | 23 ++ .../dash/xterm/DockerBootDashActions.java | 45 +++ .../boot/dash/xterm/OpenDockerTerminal.java | 68 ++++ .../build.properties | 9 + .../epl-v10.html | 328 ++++++++++++++++++ .../feature.properties | 82 +++++ .../feature.xml | 65 ++++ .../pom.xml | 35 ++ .../.gitignore | 7 + .../META-INF/MANIFEST.MF | 10 + .../build.properties | 5 + .../pom.xml | 105 ++++++ .../.gitignore | 7 + .../META-INF/MANIFEST.MF | 11 + .../build.properties | 5 + .../pom.xml | 105 ++++++ .../.gitignore | 5 + .../META-INF/MANIFEST.MF | 10 + .../build.properties | 5 + .../pom.xml | 77 ++++ .../.gitignore | 6 + .../META-INF/MANIFEST.MF | 20 ++ .../build.properties | 7 + .../css/terminal-dark-theme.css | 9 + .../icons/refresh.png | Bin 0 -> 555 bytes .../icons/refresh@2x.png | Bin 0 -> 1316 bytes .../icons/terminal.png | Bin 0 -> 398 bytes .../icons/terminal.svg | 3 + .../icons/terminal@2x.png | Bin 0 -> 653 bytes .../plugin.xml | 173 +++++++++ .../pom.xml | 65 ++++ .../ide/eclipse/xterm/XtermPlugin.java | 169 +++++++++ .../xterm/XtermServiceProcessManager.java | 165 +++++++++ .../xterm/views/OpenTerminalHandler.java | 46 +++ .../eclipse/xterm/views/SimpleUriBuilder.java | 51 +++ .../ide/eclipse/xterm/views/TerminalView.java | 285 +++++++++++++++ .../xterm/views/XtermPreferencePage.java | 34 ++ .../views/XtermPreferencesInitializer.java | 27 ++ 44 files changed, 2186 insertions(+), 1 deletion(-) create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/.gitignore create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/META-INF/MANIFEST.MF create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/build.properties create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/plugin.xml create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/pom.xml create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/src/org/springframework/ide/eclipse/boot/dash/xterm/BootDashInjections.java create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/src/org/springframework/ide/eclipse/boot/dash/xterm/DockerBootDashActions.java create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/src/org/springframework/ide/eclipse/boot/dash/xterm/OpenDockerTerminal.java create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/build.properties create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/epl-v10.html create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/feature.properties create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/feature.xml create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/pom.xml create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64/.gitignore create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64/META-INF/MANIFEST.MF create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64/build.properties create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64/pom.xml create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64/.gitignore create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64/META-INF/MANIFEST.MF create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64/build.properties create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64/pom.xml create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64/.gitignore create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64/META-INF/MANIFEST.MF create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64/build.properties create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64/pom.xml create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/.gitignore create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/META-INF/MANIFEST.MF create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/build.properties create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/css/terminal-dark-theme.css create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/icons/refresh.png create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/icons/refresh@2x.png create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/icons/terminal.png create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/icons/terminal.svg create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/icons/terminal@2x.png create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/plugin.xml create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/pom.xml create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/XtermPlugin.java create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/XtermServiceProcessManager.java create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/OpenTerminalHandler.java create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/SimpleUriBuilder.java create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/TerminalView.java create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/XtermPreferencePage.java create mode 100644 eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/XtermPreferencesInitializer.java diff --git a/eclipse-distribution/pom.xml b/eclipse-distribution/pom.xml index fac094446..84634bad0 100644 --- a/eclipse-distribution/pom.xml +++ b/eclipse-distribution/pom.xml @@ -69,7 +69,6 @@ ../eclipse-extensions/org.springframework.ide.eclipse.xml.namespaces ../eclipse-extensions/org.springframework.ide.eclipse.xml.namespaces.feature ../eclipse-extensions/org.springsource.ide.eclipse.commons.cloudfoundry.client.v2 - @@ -340,6 +339,14 @@ org.springframework.boot.ide.product.e417 + + + ../eclipse-extensions/org.springframework.ide.eclipse.xterm + ../eclipse-extensions/org.springframework.ide.eclipse.xterm.feature + ../eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64 + ../eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64 + ../eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64 + @@ -453,6 +460,13 @@ org.springframework.boot.ide.product.e418 + + + ../eclipse-extensions/org.springframework.ide.eclipse.xterm + ../eclipse-extensions/org.springframework.ide.eclipse.xterm.feature + ../eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64 + ../eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64 + ../eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64 diff --git a/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/.gitignore b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/.gitignore new file mode 100644 index 000000000..dfdbc0787 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/.gitignore @@ -0,0 +1,6 @@ +/target/ +/.settings/ +.DS_Store +/**/.DS_Store +.project +.classpath \ No newline at end of file diff --git a/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/META-INF/MANIFEST.MF b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/META-INF/MANIFEST.MF new file mode 100644 index 000000000..10139f55d --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Boot Dashboard integration with Xterm view +Bundle-SymbolicName: org.springframework.ide.eclipse.boot.dash.xterm;singleton:=true +Bundle-Version: 4.8.1.qualifier +Automatic-Module-Name: org.springframework.ide.eclipse.boot.dash.xterm +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.ui, + org.springsource.ide.eclipse.commons.livexp, + org.springframework.ide.eclipse.boot.dash, + org.springframework.ide.eclipse.boot.dash.docker, + org.springframework.ide.eclipse.xterm diff --git a/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/build.properties b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/build.properties new file mode 100644 index 000000000..e9863e281 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff --git a/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/plugin.xml b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/plugin.xml new file mode 100644 index 000000000..bfb84394f --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/plugin.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/pom.xml b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/pom.xml new file mode 100644 index 000000000..6a4d3d055 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/pom.xml @@ -0,0 +1,69 @@ + + + 4.0.0 + + org.springframework.ide.eclipse + org.springframework.ide.eclipse.parent + 3.9.15-SNAPSHOT + ../../pom.xml + + eclipse-plugin + org.springframework.ide.eclipse.boot.dash.xterm + + + 1.5.1 + + + + + + org.eclipse.tycho + target-platform-configuration + ${tycho-version} + + p2 + ignore + + + + + org.eclipse.tycho + tycho-compiler-plugin + ${tycho-version} + + + + org.eclipse.tycho + tycho-source-plugin + ${tycho-version} + + + plugin-source + generate-sources + + plugin-source + + + + + + + org.eclipse.tycho + tycho-p2-plugin + ${tycho-version} + + + second-generate-p2-metadata + + p2-metadata + + verify + + + + + + + diff --git a/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/src/org/springframework/ide/eclipse/boot/dash/xterm/BootDashInjections.java b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/src/org/springframework/ide/eclipse/boot/dash/xterm/BootDashInjections.java new file mode 100644 index 000000000..015bd4aa2 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/src/org/springframework/ide/eclipse/boot/dash/xterm/BootDashInjections.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2020 Pivotal, Inc. + * 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 + * https://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.eclipse.boot.dash.xterm; + +import org.springframework.ide.eclipse.boot.dash.di.EclipseBeanLoader.Contribution; +import org.springframework.ide.eclipse.boot.dash.views.BootDashActions; +import org.springframework.ide.eclipse.boot.dash.di.SimpleDIContext; + +public class BootDashInjections implements Contribution { + + @Override + public void applyBeanDefinitions(SimpleDIContext context) throws Exception { + context.defInstance(BootDashActions.Factory.class, DockerBootDashActions.factory); + } +} diff --git a/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/src/org/springframework/ide/eclipse/boot/dash/xterm/DockerBootDashActions.java b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/src/org/springframework/ide/eclipse/boot/dash/xterm/DockerBootDashActions.java new file mode 100644 index 000000000..447e0eb95 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/src/org/springframework/ide/eclipse/boot/dash/xterm/DockerBootDashActions.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2020 Pivotal, Inc. + * 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 + * https://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.eclipse.boot.dash.xterm; + +import java.util.Arrays; + +import org.springframework.ide.eclipse.boot.dash.di.SimpleDIContext; +import org.springframework.ide.eclipse.boot.dash.liveprocess.LiveProcessCommandsExecutor; +import org.springframework.ide.eclipse.boot.dash.livexp.MultiSelection; +import org.springframework.ide.eclipse.boot.dash.model.BootDashElement; +import org.springframework.ide.eclipse.boot.dash.model.BootDashModel; +import org.springframework.ide.eclipse.boot.dash.model.BootDashViewModel; +import org.springframework.ide.eclipse.boot.dash.views.AbstractBootDashElementsAction.Params; +import org.springframework.ide.eclipse.boot.dash.views.BootDashActions; +import org.springsource.ide.eclipse.commons.livexp.core.LiveExpression; + +public class DockerBootDashActions { + + public static BootDashActions.Factory factory = ( + BootDashActions actions, + BootDashViewModel model, + MultiSelection selection, + LiveExpression section, + SimpleDIContext context, + LiveProcessCommandsExecutor liveProcessCmds + ) -> { + + Params defaultActionParams = new Params(actions) + .setModel(model) + .setSelection(selection) + .setContext(context) + .setLiveProcessCmds(liveProcessCmds); + return Arrays.asList( + new OpenDockerTerminal(defaultActionParams) + ); + }; +} diff --git a/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/src/org/springframework/ide/eclipse/boot/dash/xterm/OpenDockerTerminal.java b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/src/org/springframework/ide/eclipse/boot/dash/xterm/OpenDockerTerminal.java new file mode 100644 index 000000000..d6104538a --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/src/org/springframework/ide/eclipse/boot/dash/xterm/OpenDockerTerminal.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2020 Pivotal, Inc. + * 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 + * https://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.eclipse.boot.dash.xterm; + +import org.eclipse.core.runtime.Platform; +import org.springframework.ide.eclipse.boot.dash.api.App; +import org.springframework.ide.eclipse.boot.dash.docker.runtarget.DockerContainer; +import org.springframework.ide.eclipse.boot.dash.model.BootDashElement; +import org.springframework.ide.eclipse.boot.dash.model.remote.GenericRemoteAppElement; +import org.springframework.ide.eclipse.boot.dash.views.AbstractBootDashElementsAction; +import org.springframework.ide.eclipse.xterm.XtermPlugin; + +public class OpenDockerTerminal extends AbstractBootDashElementsAction { + + public OpenDockerTerminal(Params params) { + super(params); + this.setText("Open Shell"); + this.setToolTipText("Open Shell in selected container"); + this.setImageDescriptor(XtermPlugin.imageDescriptorFromPlugin(XtermPlugin.getDefault().getBundle().getSymbolicName(), "icons/terminal.png")); +// this.setDisabledImageDescriptor(BootDashActivator.getImageDescriptor("icons/open_console_disabled.png")); + } + + @Override + public void run() { + DockerContainer c = getDockerContainer(); + String id = c.getName(); + if (Platform.OS_WIN32.equals(Platform.getOS())) { + XtermPlugin.getDefault().openTerminalView("docker exec -it "+id+" /bin/bash", null); + } else { + XtermPlugin.getDefault().openTerminalView("/usr/local/bin/docker exec -it "+id+" /bin/bash", null); + } + } + + + /** + * Subclass can override to compuet enablement differently. + * The default implementation enables if a single element is selected. + */ + public void updateEnablement() { + DockerContainer c = getDockerContainer(); + this.setEnabled(c!=null && c.fetchRunState().isActive()); + } + + private DockerContainer getDockerContainer() { + BootDashElement e = getSingleSelectedElement(); + if (e instanceof GenericRemoteAppElement) { + App app = ((GenericRemoteAppElement) e).getAppData(); + if (app instanceof DockerContainer) { + return (DockerContainer) app; + } + } + return null; + } + + public void updateVisibility() { + this.setVisible(getDockerContainer()!=null); + } + + +} diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/build.properties b/eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/build.properties new file mode 100644 index 000000000..d5cc70b2c --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/build.properties @@ -0,0 +1,9 @@ +bin.includes = feature.properties,\ + feature.xml,\ + epl-v10.html +src.includes = .project,\ + build.properties,\ + feature.properties,\ + feature.xml,\ + epl-v10.html +generate.feature@org.springframework.ide.eclipse.feature.source=org.springframework.ide.eclipse.feature diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/epl-v10.html b/eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/epl-v10.html new file mode 100644 index 000000000..ed4b19665 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/epl-v10.html @@ -0,0 +1,328 @@ + + + + + + + + +Eclipse Public License - Version 1.0 + + + + + + +
+ +

Eclipse Public License - v 1.0 +

+ +

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER +THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, +REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE +OF THIS AGREEMENT.

+ +

1. DEFINITIONS

+ +

"Contribution" means:

+ +

a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and
+b) in the case of each subsequent Contributor:

+ +

i) +changes to the Program, and

+ +

ii) +additions to the Program;

+ +

where +such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor +if it was added to the Program by such Contributor itself or anyone acting on +such Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in conjunction +with the Program under their own license agreement, and (ii) are not derivative +works of the Program.

+ +

"Contributor" means any person or +entity that distributes the Program.

+ +

"Licensed Patents " mean patent +claims licensable by a Contributor which are necessarily infringed by the use +or sale of its Contribution alone or when combined with the Program.

+ +

"Program" means the Contributions +distributed in accordance with this Agreement.

+ +

"Recipient" means anyone who +receives the Program under this Agreement, including all Contributors.

+ +

2. GRANT OF RIGHTS

+ +

a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly +display, publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and object code +form.

+ +

b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free +patent license under Licensed Patents to make, use, sell, offer to sell, import +and otherwise transfer the Contribution of such Contributor, if any, in source +code and object code form. This patent license shall apply to the combination +of the Contribution and the Program if, at the time the Contribution is added +by the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply to +any other combinations which include the Contribution. No hardware per se is +licensed hereunder.

+ +

c) +Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor +that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient +for claims brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For example, +if a third party patent license is required to allow Recipient to distribute +the Program, it is Recipient's responsibility to acquire that license before +distributing the Program.

+ +

d) +Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement.

+ +

3. REQUIREMENTS

+ +

A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that: +

+ +

a) +it complies with the terms and conditions of this Agreement; and

+ +

b) +its license agreement:

+ +

i) +effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose;

+ +

ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits;

+ +

iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and

+ +

iv) +states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange.

+ +

When the Program is made available in source +code form:

+ +

a) +it must be made available under this Agreement; and

+ +

b) a +copy of this Agreement must be included with each copy of the Program.

+ +

Contributors may not remove or alter any +copyright notices contained within the Program.

+ +

Each Contributor must identify itself as the +originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution.

+ +

4. COMMERCIAL DISTRIBUTION

+ +

Commercial distributors of software may +accept certain responsibilities with respect to end users, business partners +and the like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor ("Commercial +Contributor") hereby agrees to defend and indemnify every other +Contributor ("Indemnified Contributor") against any losses, damages and +costs (collectively "Losses") arising from claims, lawsuits and other +legal actions brought by a third party against the Indemnified Contributor to +the extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense.

+ +

For example, a Contributor might include the +Program in a commercial product offering, Product X. That Contributor is then a +Commercial Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under this +section, the Commercial Contributor would have to defend claims against the +other Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages.

+ +

5. NO WARRANTY

+ +

EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, +WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations.

+ +

6. DISCLAIMER OF LIABILITY

+ +

EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF +THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES.

+ +

7. GENERAL

+ +

If any provision of this Agreement is invalid +or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without +further action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable.

+ +

If Recipient institutes patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with +other software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed.

+ +

All Recipient's rights under this Agreement +shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable +period of time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive.

+ +

Everyone is permitted to copy and distribute +copies of this Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The Agreement +Steward reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement Steward has +the right to modify this Agreement. The Eclipse Foundation is the initial +Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved.

+ +

This Agreement is governed by the laws of the +State of New York and the intellectual property laws of the United States of +America. No party to this Agreement will bring a legal action under this +Agreement more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation.

+ +

 

+ +
+ + + + \ No newline at end of file diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/feature.properties b/eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/feature.properties new file mode 100644 index 000000000..6557cdde6 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/feature.properties @@ -0,0 +1,82 @@ +# feature.properties +# contains externalized strings for feature.xml +# "%foo" in feature.xml corresponds to the key "foo" in this file +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# This file should be translated. + +# "featureName" property - name of the feature +featureName=Xterm Terminal for Eclipse + +# "providerName" property - name of the company that provides the feature +providerName=Spring IDE Developers + +# "updateSiteName" property - label for the update site +updateSiteName=Spring IDE Update Site + +# "description" property - description of the feature +description=\ +This feature provides a XtermJS frontend and Node-PTY backend terminal for Eclipse + +# "copyright" property - text of the Copyright +copyright=\ +Copyright (c) 2005, 2012 Spring IDE Developers\n\ +All rights reserved. This program and the accompanying materials\n\ +are made available under the terms of the Eclipse Public License v1.0\n\ +which accompanies this distribution, and is available at\n\ +https://www.eclipse.org/legal/epl-v10.html\n\ +\n\ +Contributors:\n\ + Spring IDE Developers - initial API and implementation\n +################ end of copyright property #################################### + +# "license" property - text of the "Feature Update License" +# should be plain text version of license agreement pointed to be "licenseURL" +license=\ +SPRING IDE PROJECT SOFTWARE USER AGREEMENT\n\ +March 26, 2007\n\ +\n\ +Usage Of Content\n\ +\n\ +THE SPRING IDE PROJECT MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ +\n\ +Applicable Licenses\n\ +\n\ +Unless otherwise indicated, all Content made available by the Spring IDE Project is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is provided with this Content and is also available at https://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content.\n\ +\n\ +Content includes, but is not limited to, source code, object code, documentation and other files maintained in the springsource.org SVN repository ("Repository") in CVS modules ("Modules") and made available as downloadable archives ("Downloads").\n\ +\n\ + - Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").\n\ + - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive) in a directory named "plugins".\n\ + - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins and/or Fragments associated with that Feature.\n\ + - Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\ +\n\ +Features may also include other Features ("Included Features"). Files named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\ +\n\ +The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module including, but not limited to the following locations:\n\ +\n\ + - The top-level (root) directory\n\ + - Plug-in and Fragment directories\n\ + - Inside Plug-ins and Fragments packaged as JARs\n\ + - Sub-directories of the directory named "src" of certain Plug-ins\n\ + - Feature directories\n\ +\n\ +Note: if a Feature made available by the Spring IDE project is installed using the Eclipse Update Manager, you must agree to a license ("Feature Update License") during the installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature. Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in that directory.\n\ +\n\ +THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ +\n\ + - Eclipse Public License Version 1.0 (available at https://www.eclipse.org/legal/epl-v10.html)\n\ + - Eclipse Distribution License Version 1.0 (available at https://www.eclipse.org/licenses/edl-v1.0.html)\n\ + - Common Public License Version 1.0 (available at https://www.eclipse.org/legal/cpl-v10.html)\n\ + - Apache Software License 1.1 (available at https://www.apache.org/licenses/LICENSE)\n\ + - Apache Software License 2.0 (available at https://www.apache.org/licenses/LICENSE-2.0)\n\ + - Mozilla Public License Version 1.1 (available at https://www.mozilla.org/MPL/MPL-1.1.html)\n\ +\n\ +IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please contact the Spring IDE project to determine what terms and conditions govern that particular Content.\n\ +Cryptography\n\ +\n\ +Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted.\n\ +\n\ +Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. +########### end of license property ########################################## + +licenseUrl=epl-v10.html diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/feature.xml b/eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/feature.xml new file mode 100644 index 000000000..3df623711 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/feature.xml @@ -0,0 +1,65 @@ + + + + + %description + + + + %copyright + + + + %license + + + + + + + + + + + + + + + + diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/pom.xml b/eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/pom.xml new file mode 100644 index 000000000..7da36a20c --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.feature/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + + org.springframework.boot.ide + org.springframework.boot.ide + 4.8.1-SNAPSHOT + ../../eclipse-distribution/pom.xml + + org.springframework.ide.eclipse + org.springframework.ide.eclipse.xterm.feature + + eclipse-feature + + + + org.eclipse.tycho + tycho-p2-plugin + ${tycho-version} + + + second-generate-p2-metadata + + p2-metadata + + verify + + + + + + + + diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64/.gitignore b/eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64/.gitignore new file mode 100644 index 000000000..4c1f390d0 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64/.gitignore @@ -0,0 +1,7 @@ +/target/ +/lib/ +/.settings/ +.DS_Store +/**/.DS_Store +.project +.classpath \ No newline at end of file diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64/META-INF/MANIFEST.MF b/eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64/META-INF/MANIFEST.MF new file mode 100644 index 000000000..d94cd97b1 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64/META-INF/MANIFEST.MF @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Node-Xterm package for Linux +Bundle-SymbolicName: org.springframework.ide.eclipse.xterm.linux.x86_64 +Bundle-Version: 4.8.1.qualifier +Bundle-Vendor: VMware +Fragment-Host: org.springframework.ide.eclipse.xterm;bundle-version="4.8.1" +Automatic-Module-Name: org.springframework.ide.eclipse.xterm.linux.x86.64 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Eclipse-PlatformFilter: (& (osgi.ws=gtk) (osgi.os=linux) (osgi.arch=x86_64)) diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64/build.properties b/eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64/build.properties new file mode 100644 index 000000000..efaa0a7ff --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + lib/ diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64/pom.xml b/eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64/pom.xml new file mode 100644 index 000000000..e80fe7af0 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.linux.x86_64/pom.xml @@ -0,0 +1,105 @@ + + + 4.0.0 + + org.springframework.boot.ide + org.springframework.boot.ide + 4.8.1-SNAPSHOT + ../../eclipse-distribution/pom.xml + + eclipse-plugin + org.springframework.ide.eclipse.xterm.linux.x86_64 + + + node-xterm-0.0.2-linux-x86_64.zip + + + + + + + maven-clean-plugin + 3.1.0 + + + + ${project.basedir} + + **/lib/** + + false + + + + + + + + org.codehaus.mojo + wagon-maven-plugin + 2.0.0 + + + download-nodejs-app + generate-resources + + download-single + + + s3 + https://dist.springsource.com/release/TOOLS/node-xterm + ${archive-file} + ${project.basedir}/lib/node-xterm.zip + + + + + + + maven-antrun-plugin + + + process-resources + + + + + + + + + + + run + + + + + + + org.eclipse.tycho + target-platform-configuration + ${tycho-version} + + p2 + ignore + + + linux + gtk + x86_64 + + + + + + + + diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64/.gitignore b/eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64/.gitignore new file mode 100644 index 000000000..4c1f390d0 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64/.gitignore @@ -0,0 +1,7 @@ +/target/ +/lib/ +/.settings/ +.DS_Store +/**/.DS_Store +.project +.classpath \ No newline at end of file diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64/META-INF/MANIFEST.MF b/eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64/META-INF/MANIFEST.MF new file mode 100644 index 000000000..45088e09d --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64/META-INF/MANIFEST.MF @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Node-Xterm package for Mac OSX +Bundle-SymbolicName: org.springframework.ide.eclipse.xterm.macosx.x86_64 +Bundle-Version: 4.8.1.qualifier +Bundle-Vendor: VMware +Fragment-Host: org.springframework.ide.eclipse.xterm;bundle-version="4.8.1" +Automatic-Module-Name: org.springframework.ide.eclipse.xterm.macosx.x86.64 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Eclipse-PlatformFilter: (& (osgi.ws=cocoa) (osgi.os=macosx) (|(osgi.arch=x86_64)(osgi.arch=ppc))) + diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64/build.properties b/eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64/build.properties new file mode 100644 index 000000000..efaa0a7ff --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + lib/ diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64/pom.xml b/eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64/pom.xml new file mode 100644 index 000000000..1fbe9dc24 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.macosx.x86_64/pom.xml @@ -0,0 +1,105 @@ + + + 4.0.0 + + org.springframework.boot.ide + org.springframework.boot.ide + 4.8.1-SNAPSHOT + ../../eclipse-distribution/pom.xml + + eclipse-plugin + org.springframework.ide.eclipse.xterm.macosx.x86_64 + + + node-xterm-0.0.2-macosx-x86_64.zip + + + + + + + maven-clean-plugin + 3.1.0 + + + + ${project.basedir} + + **/lib/** + + false + + + + + + + + org.codehaus.mojo + wagon-maven-plugin + 2.0.0 + + + download-nodejs-app + generate-resources + + download-single + + + s3 + https://dist.springsource.com/release/TOOLS/node-xterm + ${archive-file} + ${project.basedir}/lib/node-xterm.zip + + + + + + + maven-antrun-plugin + + + process-resources + + + + + + + + + + + run + + + + + + + org.eclipse.tycho + target-platform-configuration + ${tycho-version} + + p2 + ignore + + + macosx + cocoa + x86_64 + + + + + + + + diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64/.gitignore b/eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64/.gitignore new file mode 100644 index 000000000..45e54e155 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64/.gitignore @@ -0,0 +1,5 @@ +/target/ +/lib/ +/.settings/ +.project +.classpath \ No newline at end of file diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64/META-INF/MANIFEST.MF b/eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64/META-INF/MANIFEST.MF new file mode 100644 index 000000000..82e45bbbd --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64/META-INF/MANIFEST.MF @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Node-Xterm package for Windows +Bundle-SymbolicName: org.springframework.ide.eclipse.xterm.win32.x86_64 +Bundle-Version: 4.8.1.qualifier +Bundle-Vendor: VMware +Fragment-Host: org.springframework.ide.eclipse.xterm;bundle-version="4.8.1" +Automatic-Module-Name: org.springframework.ide.eclipse.xterm.win32.x86.64 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Eclipse-PlatformFilter: (& (osgi.os=win32) (osgi.ws=win32) (osgi.arch=x86_64)) diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64/build.properties b/eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64/build.properties new file mode 100644 index 000000000..efaa0a7ff --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + lib/ diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64/pom.xml b/eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64/pom.xml new file mode 100644 index 000000000..2c65fa356 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm.win32.x86_64/pom.xml @@ -0,0 +1,77 @@ + + + 4.0.0 + + org.springframework.boot.ide + org.springframework.boot.ide + 4.8.1-SNAPSHOT + ../../eclipse-distribution/pom.xml + + eclipse-plugin + org.springframework.ide.eclipse.xterm.win32.x86_64 + + + https://dist.springsource.com/release/TOOLS/node-xterm/node-xterm-0.0.2-win32-x86_64.zip + + + + + + + maven-clean-plugin + 3.1.0 + + + + ${project.basedir} + + **/lib/** + + false + + + + + + + com.googlecode.maven-download-plugin + download-maven-plugin + 1.6.0 + + + fetch-node-xterm-linux + generate-resources + + wget + + + ${archive-url} + true + ${project.basedir}/lib + + + + + + + org.eclipse.tycho + target-platform-configuration + ${tycho-version} + + p2 + ignore + + + win32 + win32 + x86_64 + + + + + + + + diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm/.gitignore b/eclipse-extensions/org.springframework.ide.eclipse.xterm/.gitignore new file mode 100644 index 000000000..dfdbc0787 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm/.gitignore @@ -0,0 +1,6 @@ +/target/ +/.settings/ +.DS_Store +/**/.DS_Store +.project +.classpath \ No newline at end of file diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm/META-INF/MANIFEST.MF b/eclipse-extensions/org.springframework.ide.eclipse.xterm/META-INF/MANIFEST.MF new file mode 100644 index 000000000..4176a3c5b --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm/META-INF/MANIFEST.MF @@ -0,0 +1,20 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.springframework.ide.eclipse.xterm +Bundle-SymbolicName: org.springframework.ide.eclipse.xterm;singleton:=true +Bundle-Version: 4.8.1.qualifier +Automatic-Module-Name: org.springframework.ide.eclipse.xterm +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-Activator: org.springframework.ide.eclipse.xterm.XtermPlugin +Eclipse-BundleShape: dir +Require-Bundle: org.eclipse.ui;bundle-version="3.115.0", + org.eclipse.core.runtime, + org.eclipse.core.resources, + org.apache.httpcomponents.httpclient, + org.apache.httpcomponents.httpcore, + org.eclipse.wildwebdeveloper.embedder.node +Import-Package: javax.inject +Bundle-ClassPath: . +Bundle-ActivationPolicy: lazy +Export-Package: org.springframework.ide.eclipse.xterm, + org.springframework.ide.eclipse.xterm.views diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm/build.properties b/eclipse-extensions/org.springframework.ide.eclipse.xterm/build.properties new file mode 100644 index 000000000..e01ef8df6 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + css/,\ + icons/ diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm/css/terminal-dark-theme.css b/eclipse-extensions/org.springframework.ide.eclipse.xterm/css/terminal-dark-theme.css new file mode 100644 index 000000000..cf69e1224 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm/css/terminal-dark-theme.css @@ -0,0 +1,9 @@ +/* See bug 466075 about the pseudo-selector ":org-springframework-tooling-ls-eclipse-commons" */ +IEclipsePreferences#org-eclipse-ui-workbench:org-springframework-ide-eclipse-xterm { + preferences: + 'org.springframework.ide.eclipse.xterm.background=41,41,41' + 'org.springframework.ide.eclipse.xterm.foreground=255,255,255' + 'org.springframework.ide.eclipse.xterm.selection=235,235,235' + 'org.springframework.ide.eclipse.xterm.cursor=255,255,255' + 'org.springframework.ide.eclipse.xterm.cursorAccent=255,255,255' + diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm/icons/refresh.png b/eclipse-extensions/org.springframework.ide.eclipse.xterm/icons/refresh.png new file mode 100644 index 0000000000000000000000000000000000000000..3de2d8a113d74ad3e8de61bd247e078bd876a3c2 GIT binary patch literal 555 zcmV+`0@VG9P)YegFUK-T%YAnooB(iu>&M(17g?QcwQ9-17hb z>+LA`?~6_Uk4>?BySYZh0j~jDYsAmLK9c|c&z&AHe!4gPKZyVPcGv%xhjRY!sF&W1 z*ML=}q7vI`r5-%r;rr+3+4%q4>ZD$5t`4u^VFb5WyB zR03qk<|@gX*O%Db*j6ij8zi@>TB`fZ48vbrtEF}!MV0EoBmEj5_qU6xKtf;sIgtPI zV5gMd`~(G#m3ad7EAj=?L2@AenqrZ+s|$p45z*DH^7!3_{{Q>Cl#lJM7q>Vz#pwCp zulN6-nr;93V5dqny7!i)@rs~ES-bLMQ0P9|U-skZB$F3s=ed3O|K-O2zi*ENL)`4c zjyiFFyaBeOUS`dU<1K&CqYQ+9K3@HQYpuj}yasHn5LMaHDF67y!JI#^XoF#p*yd`9 z%>)z9`T_v~U`TJ?TqE`L%yh$-KhGxof4wL0KQI;^Z!SjjGr?3?FaP}M7Oy`WD5?GP)?Km5bQ_CDH9bYaox#ug!Q(PdHpaYlS4K4xa-GBKG+0|Q!Uc{55|XxQea zQ%7_vner%oP-rQoFFGs?>&-E)86 zb9(OYb0Q-CFPB?QA9tw*-y^lURKf#Wme`|+y4S51lpsO-XHWW?PCX3nLgC;RC6Bnr zr4o3NV8|r{);9sa*pk3qv~6TdX6{r8tf#l#D14n@faKA$-8bQxoMQy!3pFW6JYtsxg_Z2K~LGMXg@s5$)Sv7@Usnhv;`XvJ9&LBeXu@{hVF|mamoHm%$OOj)V>FJ zj4fZ#61E9z9yRPLdc^M=(XYwCiiX`Xu;x%mv}VJ}O$r{*l1=-6G9CtYta{z*`0{zc zSX*q<_v1yUht5A+Is{R zdlG`wTe=@CnKbKAZuhr-{5Xu(zXrY^#DTaulVWPqiOR6{LA9KSt4XKk>#{}cP3z0x z>v}h!j`Oi#l9OPPQQjIkIfvW5Up*Cw+wvoqP@gC4ufZUt_L^km@3nG@9ksj|NYMUi z3^G7*g{Tx2tLijDj|A6iU*O`%6odOh7Z|m0AA*X?gEre*Oz0%MSYsMFWlSa6LBn%g zg6}?w0i%oxR6>)4$1|i6a}HG$bIW@O45-063zg?=<9XeQcZ{@ayFgsLp*&hNZ3nUHCd zumQ3wRpY~0_ZHMCTrFJ304OqkoIlEGzj_R0ltDz~u?g<#ySpkBe~MU)%qH@w3cz~oz;>P9AZvxszv zegZ|!ut--U zCyv#mlhAzb33hRyc+HgiqcaO(R>;(3P;FsvMpGJ@i)y^T>0~r>!*LiE`(&`xpZ>4H zaku7C29Ghx>DWy<^BGe4N2=5K3q}Ny)w;ovFFr^uXQP+nGC~otnU_vZi%{J@rk9c> z1_@EBmlA-r8ok~#(XiZ4ezU2k-jJ&zAxGNI#c+uiI*&rrshyz1bv=czx$DWf6-g%1 zIe!OCH@yYu&fvPPP2yeHlH?pr5_ztQL>}Chzw$U=9I=&GDMD^}B2QJGaDPcf0{`jF adhcIA5OYdhzb#_`00004nJ zFvWr}9gP2NHH)la(lWs zhFJ72owzaUP=ZM7{{6vkx&K_yjW(OF&^)F7tVU&%j-A7`H)p#=mN(=lycA+TUb4lx z_ra~Uh9@PRf|{2i_~$%4WZV9`knvq3&kY9M1@?E!c1KQEl@{3bB)y?un#+t~?bfhB zkxUb**ysyP85<)!CS7~I)#m)}RZsX5wni};$n|S>F+G>L?$PkbBJ8rsq$P(RE>Q7I z>5(itn#s}R5E}Y&#myWuo`+#~`z9>Qtp8TGe|oWBL(P4AXR9o``SZnNs*)wz_8*$G z~F^Yrv!!Ub9s_uJdV;XXG@7`waQa7WzL$4>0boZz(@8 p`K8|HM$HcvAByK6;QsKBnf?nxpA7&2 literal 0 HcmV?d00001 diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm/icons/terminal.svg b/eclipse-extensions/org.springframework.ide.eclipse.xterm/icons/terminal.svg new file mode 100644 index 000000000..081a05967 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm/icons/terminal.svg @@ -0,0 +1,3 @@ + + +Untitled.svg \ No newline at end of file diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm/icons/terminal@2x.png b/eclipse-extensions/org.springframework.ide.eclipse.xterm/icons/terminal@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..9385876441c8db90568ad683e1583f535e1bbe7a GIT binary patch literal 653 zcmV;80&@L{P)X=9}pYSCWV#a ze-P9nl3-_(*ok0grGki@-{OO?QqaP?Ma@W8?)`=!uL)N{`}<7!^`U}0wGeP-sH zZwCG<0K5UtfGfZTWKUr)#ykUF11GHMDe!rZhTGy3@ML-BhctKMBXHsaUI8!Hm*fBn z0t&$S9caA@U16Rar`}H1RaXk|3s8>)V5`gKnM{U$zfZf}CL9hQ0zieue#GN(S=MAS zkz_J?h&-5o)M_N&Rqp|^+3XDfN4;K8G)?msKvh*~Hk+;xhG9rF8ubpq ziF`gUv)ODT#P#*Hq|<3{0RV}`Vq%)+MhM%srCP1-GcPtbghC-1jYh6p(r7fi1pp)v z2uQ2da)k&6gZ~V0tO~fI|8EP9nuObqVJel{m+>mVE`>96*WCejxr_#b!My;c)2TbaF4u9fSiBcNx7)ojhQj>KuE6|3lFQ{V zO_OrDjA0nuCZEqop->=^NZ|MTUHgd$x~@|yl^Bo5D@_XU6L@^9lXn`cz~zz50WMYG z!w~`A13UsQ*l%&UON@Yr4#^AP%K^;7g@j$;5+kU|3|+8PZ5z3jE7#X00000NkvXXu0mjf*NYa! literal 0 HcmV?d00001 diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm/plugin.xml b/eclipse-extensions/org.springframework.ide.eclipse.xterm/plugin.xml new file mode 100644 index 000000000..3310119f9 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm/plugin.xml @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + Xterm terminal apperance theme settings + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm/pom.xml b/eclipse-extensions/org.springframework.ide.eclipse.xterm/pom.xml new file mode 100644 index 000000000..8849289eb --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm/pom.xml @@ -0,0 +1,65 @@ + + + 4.0.0 + + org.springframework.boot.ide + org.springframework.boot.ide + 4.8.1-SNAPSHOT + ../../eclipse-distribution/pom.xml + + eclipse-plugin + org.springframework.ide.eclipse.xterm + + + + + org.eclipse.tycho + target-platform-configuration + ${tycho-version} + + p2 + ignore + + + + + org.eclipse.tycho + tycho-compiler-plugin + ${tycho-version} + + + + org.eclipse.tycho + tycho-source-plugin + ${tycho-version} + + + plugin-source + generate-sources + + plugin-source + + + + + + + org.eclipse.tycho + tycho-p2-plugin + ${tycho-version} + + + second-generate-p2-metadata + + p2-metadata + + verify + + + + + + + diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/XtermPlugin.java b/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/XtermPlugin.java new file mode 100644 index 000000000..cdf1555c4 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/XtermPlugin.java @@ -0,0 +1,169 @@ +/******************************************************************************* + * Copyright (c) 2020 Pivotal, Inc. + * 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 + * https://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.eclipse.xterm; + +import java.time.Duration; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.CancellationException; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Status; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; +import org.springframework.ide.eclipse.xterm.views.TerminalView; + +public class XtermPlugin extends AbstractUIPlugin { + + private static XtermPlugin plugin; + + private static final String PLUGIN_ID = "org.springframework.ide.eclipse.xterm"; + + public static final String BG_COLOR = "org.springframework.ide.eclipse.xterm.background"; + public static final String FG_COLOR = "org.springframework.ide.eclipse.xterm.foreground"; + public static final String SELECTION_COLOR = "org.springframework.ide.eclipse.xterm.selection"; + public static final String CURSOR_COLOR = "org.springframework.ide.eclipse.xterm.cursor"; + public static final String CURSOR_ACCENT_COLOR = "org.springframework.ide.eclipse.xterm.cursorAccent"; + public static final String FONT = "org.springframework.ide.eclipse.xterm.font"; + + public static final String PREFS_DEFAULT_SHELL_CMD = "org.springframework.ide.eclipse.xterm.defaultShellCmd"; + + private static final List NO_SHOW_EXCEPTIONS = Arrays.asList( + "ValueParseException", + "CoreException" + ); + + private XtermServiceProcessManager serviceManager = new XtermServiceProcessManager(); + + @Override + public void start(BundleContext bundle) throws Exception { + plugin = this; + } + + @Override + public void stop(BundleContext bundle) throws Exception { + serviceManager.stopService(); + plugin = null; + } + + public static XtermPlugin getDefault() { + return plugin; + } + + public static void log(String m, Throwable t) { + getDefault().getLog().error(m, t); + } + + public void openTerminalView(String cmd, String cwd) { + try { + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + String terminalId = UUID.randomUUID().toString(); + TerminalView terminalView = (TerminalView) page.showView(TerminalView.ID, terminalId, IWorkbenchPage.VIEW_ACTIVATE); + terminalView.startTerminal(terminalId, cmd, cwd); + } catch (Exception e) { + XtermPlugin.log(e); + } + } + + public CompletableFuture xtermUrl(long timeout) { + return CompletableFuture.supplyAsync(() -> { + try { + return serviceManager.serviceUrl(Duration.ofSeconds(10)); + } catch (Throwable t) { + throw new CompletionException(t); + } + }); + } + + public static void log(Throwable e) { + if (isCancelation(e)) { + //Don't log canceled operations, those aren't real errors. + return; + } + try { + XtermPlugin.getDefault().getLog().log(status(e)); + } catch (NullPointerException npe) { + //Can happen if errors are trying to be logged during Eclipse's shutdown + e.printStackTrace(); + } + } + + private static boolean isCancelation(Throwable e) { + if (e==null) { + return false; + } + Throwable cause = e.getCause(); + boolean isCancel = ( + e instanceof OperationCanceledException || + e instanceof InterruptedException || + e instanceof CancellationException || + ( + e instanceof CoreException && + ((CoreException)e).getStatus().getSeverity()==IStatus.CANCEL + ) + ); + return isCancel || ( + cause!=null && //avoid npe's on recursive check + cause!=e && //avoid infinite recursion on e == cause + isCancelation(cause) + ); + } + + private static IStatus status(Throwable e) { + if (isCancelation(e)) { + return Status.CANCEL_STATUS; + } + return status(IStatus.ERROR, e); + } + + private static IStatus status(int severity, Throwable e) { + if (e instanceof CoreException) { + IStatus status = ((CoreException) e).getStatus(); + if (status != null && status.getSeverity() == severity) { + Throwable ee = status.getException(); + if (ee != null) { + return status; + } + } + } + return new Status(severity, XtermPlugin.PLUGIN_ID, getMessage(e), e); + } + + private static String getMessage(Throwable e) { + // The message of nested exception is usually more interesting than the + // one on top. + Throwable cause = getDeepestCause(e); + String errorType = cause.getClass().getSimpleName(); + String msg = cause.getMessage(); + if (NO_SHOW_EXCEPTIONS.contains(errorType) && msg!=null) { + return msg; + } + return errorType + ": " + msg; + } + + private static Throwable getDeepestCause(Throwable e) { + Throwable cause = e; + Throwable parent = e.getCause(); + while (parent != null && parent != e) { + cause = parent; + parent = cause.getCause(); + } + return cause; + } + +} diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/XtermServiceProcessManager.java b/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/XtermServiceProcessManager.java new file mode 100644 index 000000000..1f729e5c3 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/XtermServiceProcessManager.java @@ -0,0 +1,165 @@ +/******************************************************************************* + * Copyright (c) 2020 Pivotal, Inc. + * 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 + * https://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.eclipse.xterm; + +import java.io.File; +import java.io.IOException; +import java.net.ServerSocket; +import java.net.URISyntaxException; +import java.net.URL; +import java.time.Duration; +import java.util.concurrent.TimeoutException; + +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.HttpClientBuilder; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.wildwebdeveloper.embedder.node.NodeJSManager; +import org.osgi.framework.Bundle; + + +class XtermServiceProcessManager { + + private static final int INVALID_PORT = -1; + + private static final String NODEJS_SYSTEM_PROPERTY = "org.springframework.xterm.nodejs"; + + private HttpClient httpClient = HttpClientBuilder.create().build(); + + private Process process; + + private int port = INVALID_PORT; + + synchronized void startProcess() throws IOException { + port = findFreePort(); + Bundle bundle = XtermPlugin.getDefault().getBundle(); + URL url = FileLocator.find(bundle, new Path("/lib/node_modules/node-xterm/terminal-server.js"), null); +// URL url = FileLocator.find(bundle, new Path("/lib/terminal-server.js"), null); +// URL url = FileLocator.find(bundle, new Path("/lib/node-xterm-macos"), null); +// URL url = FileLocator.find(bundle, new Path("/lib/node-xterm-win.exe"), null); + url = FileLocator.toFileURL(url); + try { + File serverJsFile = new File(url.toURI()); + if (serverJsFile == null || !serverJsFile.exists()) { + throw new IllegalStateException("Cannot find file " + serverJsFile + ". Cannot start xterm service!"); + } + File nodeJs = null; + if (System.getProperty(NODEJS_SYSTEM_PROPERTY) != null) { + nodeJs = new File(System.getProperty(NODEJS_SYSTEM_PROPERTY)); + } else { + nodeJs = NodeJSManager.getNodeJsLocation(); + } + if (nodeJs == null || !nodeJs.exists()) { + throw new IllegalStateException("Cannot find NodeJS executable at '" + nodeJs + "'. Cannot start xterm service!"); + } + ProcessBuilder builder = new ProcessBuilder( + nodeJs.toString(), + serverJsFile.toString(), + "--server.port=" + port, + "--terminal.pty.shutdown=delay", // terminal pty process destroyed right after sockets closed + "--terminal.pty.shutdown-delay=5", + "--terminal.auto-shutdown.on=true", // terminal app can shutdown itself if not used + "--terminal.auto-shutdown.delay=30" // terminal app shuts itself down in not used for 30 sec + ); + + File logFile = Platform.getStateLocation(XtermPlugin.getDefault().getBundle()).append("xterm-log.log").toFile(); + builder.redirectError(logFile); + builder.redirectOutput(logFile); + + process = builder.start(); + } catch (URISyntaxException e) { + throw new IllegalStateException(e); + } + } + + synchronized private void waitUntilStarted(Duration timeout) throws TimeoutException, InterruptedException { + long start = System.currentTimeMillis(); + long timeoutMillis = timeout.toMillis(); + do { + if (System.currentTimeMillis() - start > timeoutMillis) { + throw new TimeoutException("Timed out waiting for Xterm service to start"); + } + Thread.sleep(150); + } while (!isStarted(port)); + } + + synchronized private boolean isStarted(int port) { + HttpGet request = new HttpGet("http://localhost:" + port); + try { + HttpResponse response = httpClient.execute(request); + if (response.getStatusLine().getStatusCode() == 200) { + return true; + } + } catch (IOException e) { + // Ignore + } + return false; + } + + synchronized void stopService() { + if (process != null && process.isAlive()) { + if (port > 0) { + HttpPost request = new HttpPost("http://localhost:" + port + "/shutdown"); + request.setHeader("Content-Type", "application/json"); + try { + HttpResponse response = httpClient.execute(request); + int code = response.getStatusLine().getStatusCode(); + if (code != 200) { + process.destroy(); + } + } catch (ClientProtocolException e) { + throw new RuntimeException(e); + } catch (IOException e) { + process.destroy(); + } + } else { + process.destroy(); + } + } + process = null; + } + + synchronized String serviceUrl(Duration timeout) throws Exception { + if (port == INVALID_PORT && process != null && process.isAlive()) { + process.destroy(); + process = null; + } + if (process == null || !process.isAlive()) { + startProcess(); + try { + waitUntilStarted(timeout); + } catch (Exception e) { + this.port = INVALID_PORT; + throw e; + } + } + return "http://localhost:" + port; + } + + private static int findFreePort() throws IOException { + ServerSocket socket = new ServerSocket(0); + try { + return socket.getLocalPort(); + } finally { + try { + socket.close(); + } catch (IOException e) { + } + } + } + + +} diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/OpenTerminalHandler.java b/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/OpenTerminalHandler.java new file mode 100644 index 000000000..b43825563 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/OpenTerminalHandler.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2020 Pivotal, Inc. + * 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 + * https://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.eclipse.xterm.views; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.ui.handlers.HandlerUtil; +import org.springframework.ide.eclipse.xterm.XtermPlugin; + +public class OpenTerminalHandler extends AbstractHandler implements IHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + try { + Object obj = HandlerUtil.getCurrentStructuredSelection(event).getFirstElement(); + IProject project = null; + if (obj instanceof IProject) { + project = (IProject) obj; + } else if (obj instanceof IAdaptable) { + project = ((IAdaptable)obj).getAdapter(IProject.class); + } + if (project == null) { + throw new ExecutionException("Cannot find folder for element " + obj); + } + String cwd = project.getLocation().toOSString(); + XtermPlugin.getDefault().openTerminalView(null, cwd); + } catch (Exception e) { + throw new ExecutionException("Failed to open terminal", e); + } + return null; + } + + +} diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/SimpleUriBuilder.java b/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/SimpleUriBuilder.java new file mode 100644 index 000000000..0255235f6 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/SimpleUriBuilder.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2020 Pivotal, Inc. + * 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 + * https://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.eclipse.xterm.views; + +import java.net.URLEncoder; + +import org.springframework.ide.eclipse.xterm.XtermPlugin; + +class SimpleUriBuilder { + + private final StringBuilder builder; + + private int numparams = 0; + + public SimpleUriBuilder(String baseUrl) { + builder = new StringBuilder(baseUrl); + } + + public void addParameter(String name, String paramValue) { + try { + if (numparams==0) { + builder.append("?"); + } else { + builder.append("&"); + } + numparams++; + + builder.append(URLEncoder.encode(name, "UTF-8")); + if (paramValue!=null) { + builder.append("="); + builder.append(URLEncoder.encode(paramValue, "UTF-8")); + } + } catch (Exception e) { + XtermPlugin.log(e); + } + } + + @Override + public String toString() { + return builder.toString(); + } + +} \ No newline at end of file diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/TerminalView.java b/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/TerminalView.java new file mode 100644 index 000000000..674c28b5d --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/TerminalView.java @@ -0,0 +1,285 @@ +/******************************************************************************* + * Copyright (c) 2020 Pivotal, Inc. + * 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 + * https://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.eclipse.xterm.views; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +import javax.inject.Inject; + +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.dialogs.MessageDialog; +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.browser.Browser; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.graphics.RGBA; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.IViewSite; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.ViewPart; +import org.eclipse.ui.themes.ITheme; +import org.springframework.ide.eclipse.xterm.XtermPlugin; + +public class TerminalView extends ViewPart { + + private static final String CWD_PARAM = "cwd"; + private static final String CMD_PARAM = "cmd"; + private static final String TERMINAL_ID_PARAM = "terminal"; + private static final String DEFAULT_TERMINAL_ID = "default"; + private static final String ERROR_DIALOG_TITLE = "Error Opening Xterm"; + private static final String ERROR_DIALOG_MESSAGE = "Failed to determine if Xterm service is running.\n"; + + /** + * The ID of the view as specified by the extension. + */ + public static final String ID = "org.springframework.ide.eclipse.xterm.views.TerminalView"; + + @Inject IWorkbench workbench; + + private Action refreshAction; + + private Browser browser; + + private String terminalId = DEFAULT_TERMINAL_ID; + + private String cmd; + + private String cwd; + + private boolean isNewView; + + private final IPropertyChangeListener PROPERTY_LISTENER = new IPropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent event) { + switch (event.getProperty()) { + case XtermPlugin.BG_COLOR: + case XtermPlugin.FG_COLOR: + case XtermPlugin.SELECTION_COLOR: + case XtermPlugin.CURSOR_COLOR: + case XtermPlugin.CURSOR_ACCENT_COLOR: + case XtermPlugin.FONT: + refresh(); + break; + default: + } + } + + }; + + @Override + public void createPartControl(Composite parent) { + PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(PROPERTY_LISTENER); + browser = new Browser(parent, SWT.CHROMIUM); + makeActions(); + contributeToActionBars(); + if (isNewView) { + // Non-default Xterm views are initialized with #startTerminal(...) call which will use Xterm service with the right parameters + if (isDefault()) { + navigateToTerminal(terminalId, null, ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString()); + } + } else { + navigateToTerminal(terminalId, cmd, cwd == null ? ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString() : cwd); + } + } + + private boolean isDefault() { + // Secondary id is present only for non-default Terminal views + return getViewSite().getSecondaryId() == null; + } + + @Override + public void saveState(IMemento memento) { + if (terminalId != null) { + memento.putString(TERMINAL_ID_PARAM, terminalId); + if (cmd != null) { + memento.putString(CMD_PARAM, cmd); + } + if (cwd != null) { + memento.putString(CWD_PARAM, cwd); + } + } + super.saveState(memento); + } + + @Override + public void init(IViewSite site, IMemento memento) throws PartInitException { + super.init(site, memento); + isNewView = memento == null; + if (memento != null) { + terminalId = memento.getString(TERMINAL_ID_PARAM); + if (terminalId == null) { + terminalId = DEFAULT_TERMINAL_ID; + } else { + cmd = memento.getString(CMD_PARAM); + cwd = memento.getString(CWD_PARAM); + } + } + } + + public CompletableFuture refresh() { + return navigateToTerminal(terminalId, null, ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString()); + } + + private CompletableFuture navigateToTerminal(final String terminalId, final String cmd, final String cwd) { + return CompletableFuture.runAsync(() -> { + try { + String serviceUrl = XtermPlugin.getDefault().xtermUrl(10_000).get(); + if (Display.getCurrent() != null) { + if (browser != null && !browser.isDisposed() && terminalId.equals(TerminalView.this.terminalId)) { + browser.setUrl(createUrl(serviceUrl, terminalId, cmd, cwd)); + } + } else { + Display display = PlatformUI.getWorkbench().getDisplay(); + if (display != null && !display.isDisposed()) { + display.asyncExec(() -> { + if (browser != null && !browser.isDisposed() && terminalId.equals(TerminalView.this.terminalId)) { + String url = createUrl(serviceUrl, terminalId, cmd, cwd); + browser.setUrl(url); + } + }); + } + } + } catch (ExecutionException e) { + // TODO show error page in the browser + XtermPlugin.log(e); + if (e.getCause() != null) { + StringBuilder errorMessage = new StringBuilder(ERROR_DIALOG_MESSAGE); + errorMessage.append('\n'); + errorMessage.append(e.getCause().getMessage()); + if (Display.getCurrent() != null) { + MessageDialog.openError(Display.getCurrent().getActiveShell(), ERROR_DIALOG_TITLE, errorMessage.toString()); + } else { + Display display = PlatformUI.getWorkbench().getDisplay(); + if (display != null && !display.isDisposed()) { + display.asyncExec(() -> + MessageDialog.openError(Display.getCurrent().getActiveShell(), ERROR_DIALOG_TITLE, errorMessage.toString()) + ); + } + } + } + } catch (InterruptedException e) { + XtermPlugin.log(e); + } + }); + } + + public CompletableFuture startTerminal(String terminalId, String cmd, String cwd) { + this.terminalId = terminalId; + this.cmd = cmd; + this.cwd = cwd; + return navigateToTerminal(terminalId, cmd, cwd); + } + + private String createUrl(String serviceUrl, String terminalId, String cmd, String cwd) { + SimpleUriBuilder urlBuilder = new SimpleUriBuilder(serviceUrl + "/terminal/" + terminalId); + + ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); + ColorRegistry colorRegistry = theme.getColorRegistry(); + Font font = theme.getFontRegistry().get(XtermPlugin.FONT); + + urlBuilder.addParameter("bg", rgbToUrlParameter(colorRegistry.get(XtermPlugin.BG_COLOR).getRGB())); + urlBuilder.addParameter("fg", rgbToUrlParameter(colorRegistry.get(XtermPlugin.FG_COLOR).getRGB())); + RGB selectionColor = colorRegistry.get(XtermPlugin.SELECTION_COLOR).getRGB(); + // add transparency to selection color + urlBuilder.addParameter("selection", rgbaToUrlParameter(new RGBA(selectionColor.red, selectionColor.green, selectionColor.blue, 51))); + urlBuilder.addParameter("cursor", rgbToUrlParameter(colorRegistry.get(XtermPlugin.CURSOR_COLOR).getRGB())); + urlBuilder.addParameter("cursorAccent", rgbToUrlParameter(colorRegistry.get(XtermPlugin.CURSOR_ACCENT_COLOR).getRGB())); + + urlBuilder.addParameter("fontFamily", font.getFontData()[0].getName()); + urlBuilder.addParameter("fontSize", String.valueOf(font.getFontData()[0].getHeight())); + + if (cmd != null && !cmd.isEmpty()) { + urlBuilder.addParameter(CMD_PARAM, cmd); + } else { + urlBuilder.addParameter(CMD_PARAM, + XtermPlugin.getDefault().getPreferenceStore().getString(XtermPlugin.PREFS_DEFAULT_SHELL_CMD)); + } + if (cwd != null && !cwd.isEmpty()) { + urlBuilder.addParameter(CWD_PARAM, cwd); + } + + return urlBuilder.toString(); + + } + + private static String rgbToUrlParameter(RGB rgb) { + StringBuilder sb = new StringBuilder("rgb("); + sb.append(rgb.red); + sb.append(","); + sb.append(rgb.green); + sb.append(","); + sb.append(rgb.blue); + sb.append(")"); + return sb.toString(); + } + + private static String rgbaToUrlParameter(RGBA rgba) { + StringBuilder sb = new StringBuilder("rgba("); + sb.append(rgba.rgb.red); + sb.append(","); + sb.append(rgba.rgb.green); + sb.append(","); + sb.append(rgba.rgb.blue); + sb.append(","); + sb.append(rgba.alpha / 255.0); + sb.append(")"); + return sb.toString(); + } + + private void contributeToActionBars() { + IActionBars bars = getViewSite().getActionBars(); + fillLocalPullDown(bars.getMenuManager()); + fillLocalToolBar(bars.getToolBarManager()); + } + + private void fillLocalPullDown(IMenuManager manager) { + manager.add(refreshAction); + } + + private void fillLocalToolBar(IToolBarManager manager) { + manager.add(refreshAction); + } + + private void makeActions() { + refreshAction = new Action() { + public void run() { + refresh(); + } + }; + refreshAction.setText("Refresh"); + refreshAction.setToolTipText("Refresh Terminal"); + refreshAction.setImageDescriptor(XtermPlugin.imageDescriptorFromPlugin(XtermPlugin.getDefault().getBundle().getSymbolicName(), "icons/refresh.png")); + } + + @Override + public void setFocus() { + browser.setFocus(); + } + + @Override + public void dispose() { + PlatformUI.getWorkbench().getThemeManager().removePropertyChangeListener(PROPERTY_LISTENER); + } + +} diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/XtermPreferencePage.java b/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/XtermPreferencePage.java new file mode 100644 index 000000000..2aeec7686 --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/XtermPreferencePage.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2020 Pivotal, Inc. + * 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 + * https://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.eclipse.xterm.views; + +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.StringFieldEditor; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.springframework.ide.eclipse.xterm.XtermPlugin; + +public class XtermPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + + @Override + public void init(IWorkbench workbench) { + setDescription("Xterm terminal preferences"); + setPreferenceStore(XtermPlugin.getDefault().getPreferenceStore()); + } + + @Override + protected void createFieldEditors() { + Composite parent = getFieldEditorParent(); + addField(new StringFieldEditor(XtermPlugin.PREFS_DEFAULT_SHELL_CMD, "Shell Command", parent)); + } + +} diff --git a/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/XtermPreferencesInitializer.java b/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/XtermPreferencesInitializer.java new file mode 100644 index 000000000..e8d0a474f --- /dev/null +++ b/eclipse-extensions/org.springframework.ide.eclipse.xterm/src/org/springframework/ide/eclipse/xterm/views/XtermPreferencesInitializer.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2020 Pivotal, Inc. + * 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 + * https://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.eclipse.xterm.views; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.springframework.ide.eclipse.xterm.XtermPlugin; + +public class XtermPreferencesInitializer extends AbstractPreferenceInitializer { + + public XtermPreferencesInitializer() { + } + + @Override + public void initializeDefaultPreferences() { + XtermPlugin.getDefault().getPreferenceStore().setDefault(XtermPlugin.PREFS_DEFAULT_SHELL_CMD, Platform.OS_WIN32.equals(Platform.getOS()) ? "cmd.exe" : "/bin/bash"); + } + +}