Xterm view for OS terminal in Eclipse
This commit is contained in:
6
eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/.gitignore
vendored
Normal file
6
eclipse-extensions/org.springframework.ide.eclipse.boot.dash.xterm/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/target/
|
||||
/.settings/
|
||||
.DS_Store
|
||||
/**/.DS_Store
|
||||
.project
|
||||
.classpath
|
||||
@@ -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
|
||||
@@ -0,0 +1,5 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="org.springframework.ide.eclipse.boot.dash.injections">
|
||||
<injection
|
||||
class="org.springframework.ide.eclipse.boot.dash.xterm.BootDashInjections">
|
||||
</injection>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="https://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.ide.eclipse</groupId>
|
||||
<artifactId>org.springframework.ide.eclipse.parent</artifactId>
|
||||
<version>3.9.15-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<artifactId>org.springframework.ide.eclipse.boot.dash.xterm</artifactId>
|
||||
|
||||
<properties>
|
||||
<tycho-version>1.5.1</tycho-version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
<artifactId>target-platform-configuration</artifactId>
|
||||
<version>${tycho-version}</version>
|
||||
<configuration>
|
||||
<resolver>p2</resolver>
|
||||
<pomDependencies>ignore</pomDependencies>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
<artifactId>tycho-compiler-plugin</artifactId>
|
||||
<version>${tycho-version}</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
<artifactId>tycho-source-plugin</artifactId>
|
||||
<version>${tycho-version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>plugin-source</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>plugin-source</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
<artifactId>tycho-p2-plugin</artifactId>
|
||||
<version>${tycho-version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>second-generate-p2-metadata</id>
|
||||
<goals>
|
||||
<goal>p2-metadata</goal>
|
||||
</goals>
|
||||
<phase>verify</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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<BootDashElement> selection,
|
||||
LiveExpression<BootDashModel> section,
|
||||
SimpleDIContext context,
|
||||
LiveProcessCommandsExecutor liveProcessCmds
|
||||
) -> {
|
||||
|
||||
Params defaultActionParams = new Params(actions)
|
||||
.setModel(model)
|
||||
.setSelection(selection)
|
||||
.setContext(context)
|
||||
.setLiveProcessCmds(liveProcessCmds);
|
||||
return Arrays.asList(
|
||||
new OpenDockerTerminal(defaultActionParams)
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user