Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2014-02-12 10:53:04 -0500
committerUwe Stieber2014-02-12 10:53:45 -0500
commite350dafcdd9a0e3c7d0d0aeb049fa88fb8bf9b06 (patch)
treed01aa08b365bf4538e21742464d2f8d6aae9e601
parent84d205d2a3f00a764cd900ed2fb10334ff81f57d (diff)
downloadorg.eclipse.tcf-e350dafcdd9a0e3c7d0d0aeb049fa88fb8bf9b06.tar.gz
org.eclipse.tcf-e350dafcdd9a0e3c7d0d0aeb049fa88fb8bf9b06.tar.xz
org.eclipse.tcf-e350dafcdd9a0e3c7d0d0aeb049fa88fb8bf9b06.zip
Target Explorer: Fix empty terminal tab left in terminals view if a process launch via the process connector fails. Tell the user what happened by showing a proper error message.
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/META-INF/MANIFEST.MF2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnector.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/help/IContextHelpIds.java31
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/nls/Messages.java1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/nls/Messages.properties5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/manager/ConsoleManager.java40
6 files changed, 96 insertions, 5 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/META-INF/MANIFEST.MF
index 025256198..86614ebc5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/META-INF/MANIFEST.MF
@@ -10,6 +10,7 @@ Require-Bundle: org.eclipse.cdt.core;bundle-version="5.6.0",
org.eclipse.core.runtime;bundle-version="3.8.0",
org.eclipse.tcf.te.runtime;bundle-version="1.2.0",
org.eclipse.tcf.te.runtime.services;bundle-version="1.2.0",
+ org.eclipse.tcf.te.runtime.statushandler;bundle-version="1.2.0",
org.eclipse.tcf.te.ui.terminals;bundle-version="1.2.0",
org.eclipse.tcf.te.ui.swt;bundle-version="1.2.0",
org.eclipse.tm.terminal;bundle-version="3.2.100",
@@ -19,4 +20,5 @@ Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Export-Package: org.eclipse.tcf.te.ui.terminals.process,
org.eclipse.tcf.te.ui.terminals.process.activator;x-internal:=true,
+ org.eclipse.tcf.te.ui.terminals.process.help,
org.eclipse.tcf.te.ui.terminals.process.nls;x-internal:=true
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnector.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnector.java
index e5b0a6579..2203ae007 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnector.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnector.java
@@ -22,9 +22,13 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.custom.CTabItem;
import org.eclipse.tcf.te.runtime.services.interfaces.constants.ILineSeparatorConstants;
+import org.eclipse.tcf.te.runtime.statushandler.StatusHandlerUtil;
import org.eclipse.tcf.te.runtime.utils.Env;
+import org.eclipse.tcf.te.ui.terminals.manager.ConsoleManager;
import org.eclipse.tcf.te.ui.terminals.process.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.terminals.process.help.IContextHelpIds;
import org.eclipse.tcf.te.ui.terminals.process.nls.Messages;
import org.eclipse.tcf.te.ui.terminals.streams.AbstractStreamsConnector;
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
@@ -182,9 +186,21 @@ public class ProcessConnector extends AbstractStreamsConnector {
monitor = new ProcessMonitor(this);
monitor.startMonitoring();
} catch (IOException e) {
- IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
- NLS.bind(Messages.ProcessConnector_error_creatingProcess, e.getLocalizedMessage()), e);
- UIPlugin.getDefault().getLog().log(status);
+ // Disconnect right away
+ disconnect();
+ // Lookup the tab item
+ CTabItem item = ConsoleManager.getInstance().findConsole(control);
+ if (item != null) item.dispose();
+ // Get the error message from the exception
+ String msg = e.getLocalizedMessage() != null ? e.getLocalizedMessage() : ""; //$NON-NLS-1$
+ Assert.isNotNull(msg);
+ // Strip away "Exec_tty error:"
+ msg = msg.replace("Exec_tty error:", "").trim(); //$NON-NLS-1$ //$NON-NLS-2$
+ // Repackage into a more user friendly error
+ msg = NLS.bind(Messages.ProcessConnector_error_creatingProcess, settings.getImage(), msg);
+ // Create the status object
+ IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), msg, e);
+ StatusHandlerUtil.handleStatus(status, this, msg, Messages.ProcessConnector_error_title, IContextHelpIds.MESSAGE_CREATE_PROCESS_FAILED, this, null);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/help/IContextHelpIds.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/help/IContextHelpIds.java
new file mode 100644
index 000000000..3fb81c57f
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/help/IContextHelpIds.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Wind River Systems, Inc. and others. 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 http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.terminals.process.help;
+
+import org.eclipse.tcf.te.ui.terminals.process.activator.UIPlugin;
+
+
+/**
+ * Context help id definitions.
+ */
+public interface IContextHelpIds {
+
+ /**
+ * UI plug-in common context help id prefix.
+ */
+ public final static String PREFIX = UIPlugin.getUniqueIdentifier() + "."; //$NON-NLS-1$
+
+ // ***** Message dialog boxes *****
+
+ /**
+ * Process connector: Create process failed
+ */
+ public final static String MESSAGE_CREATE_PROCESS_FAILED = PREFIX + ".status.messageCreateProcessFailed"; //$NON-NLS-1$
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/nls/Messages.java
index 220381438..804233826 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/nls/Messages.java
@@ -29,5 +29,6 @@ public class Messages extends NLS {
// **** Declare externalized string id's down here *****
+ public static String ProcessConnector_error_title;
public static String ProcessConnector_error_creatingProcess;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/nls/Messages.properties
index 7b9d33ac4..a3755e8a0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/nls/Messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+# Copyright (c) 2012, 2014 Wind River Systems, Inc. and others. 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 http://www.eclipse.org/legal/epl-v10.html
@@ -8,4 +8,5 @@
# Wind River Systems - initial API and implementation
###############################################################################
-ProcessConnector_error_creatingProcess=Exception when creating process. Possibly caused by: {0}
+ProcessConnector_error_title=Error
+ProcessConnector_error_creatingProcess=Failed to execute ''{0}''.\n\nPossibly caused by:\n{1}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/manager/ConsoleManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/manager/ConsoleManager.java
index 2136f6ee0..1c087fdff 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/manager/ConsoleManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/manager/ConsoleManager.java
@@ -19,6 +19,7 @@ import java.util.Map;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.widgets.Display;
import org.eclipse.tcf.te.ui.terminals.activator.UIPlugin;
@@ -29,6 +30,7 @@ import org.eclipse.tcf.te.ui.terminals.tabs.TabFolderManager;
import org.eclipse.tcf.te.ui.terminals.view.TerminalsView;
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
+import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
import org.eclipse.ui.IPerspectiveDescriptor;
import org.eclipse.ui.IPerspectiveListener;
import org.eclipse.ui.IViewPart;
@@ -501,6 +503,44 @@ public class ConsoleManager {
}
/**
+ * Lookup a console which is assigned with the given terminal control.
+ * <p>
+ * <b>Note:</b> The method must be called within the UI thread.
+ *
+ * @param control The terminal control. Must not be <code>null</code>.
+ * @return The corresponding console tab item or <code>null</code>.
+ */
+ public CTabItem findConsole(ITerminalControl control) {
+ Assert.isNotNull(control);
+
+ CTabItem item = null;
+
+ IWorkbenchPage page = getActiveWorkbenchPage();
+ if (page != null) {
+ IViewReference[] refs = page.getViewReferences();
+ for (int i = 0; i < refs.length; i++) {
+ IViewReference ref = refs[i];
+ IViewPart part = ref != null ? ref.getView(false) : null;
+ if (part instanceof ITerminalsView) {
+ CTabFolder tabFolder = (CTabFolder) part.getAdapter(CTabFolder.class);
+ if (tabFolder == null) continue;
+ CTabItem[] candidates = tabFolder.getItems();
+ for (CTabItem candidate : candidates) {
+ Object data = candidate.getData();
+ if (data instanceof ITerminalControl && control.equals(data)) {
+ item = candidate;
+ break;
+ }
+ }
+ }
+ if (item != null) break;
+ }
+ }
+
+ return item;
+ }
+
+ /**
* Search all console views for the one that contains a specific connector.
* <p>
* <b>Note:</b> The method will handle unified console titles itself.

Back to the top