Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2015-06-05 22:56:19 -0400
committerJeff Johnston2015-06-05 23:33:01 -0400
commita8161780a8c832a315af49cde935f4f7910a8b8a (patch)
tree77c79b14d55c94c635dd637850bed5681ff4e067
parent7e9320750bc0bde90a51602ef2bdca3b923aeb69 (diff)
downloadorg.eclipse.linuxtools-a8161780a8c832a315af49cde935f4f7910a8b8a.tar.gz
org.eclipse.linuxtools-a8161780a8c832a315af49cde935f4f7910a8b8a.tar.xz
org.eclipse.linuxtools-a8161780a8c832a315af49cde935f4f7910a8b8a.zip
Revert some of the changes made for RunImage wizard
- the RunConsole needs the additional ids to allow a permanent console for launching in a Container (e.g. gdbserver for C/C++) - the findConsole() methods need to be reinstated so a default Container console doesn't match the special permanent console Change-Id: Ic1939178fac2bf01d874c933c1f9ba606e362f7e Reviewed-on: https://git.eclipse.org/r/49583 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> Tested-by: Jeff Johnston <jjohnstn@redhat.com>
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/RunConsole.java93
1 files changed, 67 insertions, 26 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/RunConsole.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/RunConsole.java
index 33e7fa9424..36f9b88c3f 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/RunConsole.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/RunConsole.java
@@ -43,8 +43,11 @@ public class RunConsole extends IOConsole {
/** Id of this console. */
public static final String ID = "containerLog"; //$NON-NLS-1$
public static final String CONTAINER_LOG_TITLE = "ContainerLog.title"; //$NON-NLS-1$
+ public static final String DEFAULT_ID = "__DEFAULT_ID__"; //$NON-NLS-1$
private String containerId;
+ private String id;
+
private OutputStream outputStream;
private boolean attached = false;
private final WritableByteChannel[] ptyOutRef = new WritableByteChannel[1];
@@ -53,17 +56,48 @@ public class RunConsole extends IOConsole {
* Returns a reference to the console that is for the given container id. If
* such a console does not yet exist, it will be created.
*
+ * @param containerId
+ * The container id this console will be for. Must not be
+ * <code>null</code>.
+ * @return A console instance or <code>null</code> if the given containerId
+ * was <code>null</code>.
+ */
+ public static RunConsole findConsole(String containerId) {
+ if (containerId == null)
+ return null;
+ return findConsole(containerId, DEFAULT_ID);
+ }
+
+ /**
+ * Returns a reference to the console that is for the given container id. If
+ * such a console does not yet exist, it will be created.
+ *
* @param container
- * The container this console will be for. Should not be
+ * The container this console will be for. Must not be
* <code>null</code>.
- * @return A console instance or <code>null</code> if the given container
+ * @return A console instance or <code>null</code> if the given containerId
* was <code>null</code>.
*/
- public static RunConsole findConsole(final IDockerContainer container) {
- if (container == null) {
+ public static RunConsole findConsole(IDockerContainer container) {
+ if (container == null)
return null;
- }
- return findConsole(container.id(), container.name());
+ return findConsole(container.id(), DEFAULT_ID);
+ }
+
+ /**
+ * Returns a reference to the console that is for the given container id. If
+ * such a console does not yet exist, it will be created.
+ *
+ * @param containerId
+ * The container this console will be for. Must not be
+ * <code>null</code>.
+ * @param id
+ * The secondary id used to identify consoles belonging to
+ * various owners.
+ * @return A console instance.
+ */
+ public static RunConsole findConsole(String containerId, String id) {
+ return findConsole(containerId, id, containerId.substring(0, 8));
}
/**
@@ -80,20 +114,25 @@ public class RunConsole extends IOConsole {
* the name of the console to create if it did not already exist
* @return A console instance.
*/
- public static RunConsole findConsole(final String containerId,
- final String name) {
+ public static RunConsole findConsole(String containerId, String id,
+ String name) {
+ RunConsole ret = null;
for (IConsole cons : ConsolePlugin.getDefault().getConsoleManager()
.getConsoles()) {
if (cons instanceof RunConsole
- && ((RunConsole) cons).containerId.equals(containerId)) {
- return (RunConsole) cons;
+ && ((RunConsole) cons).containerId.equals(containerId)
+ && ((RunConsole) cons).id.equals(id)) {
+ ret = (RunConsole) cons;
}
}
// no existing console, create new one
- final RunConsole console = new RunConsole(containerId, name);
- ConsolePlugin.getDefault().getConsoleManager()
- .addConsoles(new IConsole[] { console });
- return console;
+ if (ret == null) {
+ ret = new RunConsole(containerId, id, name);
+ ConsolePlugin.getDefault().getConsoleManager()
+ .addConsoles(new IConsole[] { ret });
+ }
+
+ return ret;
}
@Override
@@ -125,13 +164,14 @@ public class RunConsole extends IOConsole {
public void run() {
try {
DockerConnection conn = (DockerConnection) connection;
- if (conn.getContainerInfo(containerId).config().openStdin()) {
+ if (conn.getContainerInfo(containerId).config()
+ .openStdin()) {
while (!conn.getContainerInfo(containerId).state()
.running()) {
Thread.sleep(1000);
}
- WritableByteChannel pty_out = conn.attachCommand(
- containerId, in, out);
+ WritableByteChannel pty_out = conn
+ .attachCommand(containerId, in, out);
if (conn.getContainerInfo(containerId).config().tty()) {
ptyOutRef[0] = pty_out;
}
@@ -217,10 +257,11 @@ public class RunConsole extends IOConsole {
* @param name
* The name to use for the console.
*/
- private RunConsole(String containerId, String name) {
+ private RunConsole(String containerId, String id, String name) {
super(DVMessages.getFormattedString(CONTAINER_LOG_TITLE, name), ID,
null, true);
this.containerId = containerId;
+ this.id = id;
}
/*
@@ -268,8 +309,8 @@ public class RunConsole extends IOConsole {
isCtrlOn = false;
break;
case TAB_CODE:
- pty_out.write(ByteBuffer
- .wrap(new byte[] { 9, 9 }, 0, 2));
+ pty_out.write(
+ ByteBuffer.wrap(new byte[] { 9, 9 }, 0, 2));
break;
}
} catch (IOException e1) {
@@ -283,16 +324,16 @@ public class RunConsole extends IOConsole {
WritableByteChannel pty_out = ptyOutRef[0];
try {
switch (e.keyCode) {
- /*
- * TODO : These values are configurable, so we should start
- * using 'stty -a' to know what they really are.
- */
+ /*
+ * TODO : These values are configurable, so we should
+ * start using 'stty -a' to know what they really are.
+ */
case C_CODE:
// ETX (End Of Text) (3) is usually the interrupt
// signal.
if (isCtrlOn) {
- pty_out.write(ByteBuffer.wrap(new byte[] { 3 }, 0,
- 1));
+ pty_out.write(
+ ByteBuffer.wrap(new byte[] { 3 }, 0, 1));
}
break;
case CTRL_CODE:

Back to the top