mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Bug 522289: Handle case of no terminal connectors available
The existing code had the assumption that >= 1 connector was installed in the IDE. It is difficult to configure the IDE with no connectors as the base terminal feature includes connectors, but it is technically possible. So in that case display a simple error message and avoid a hidden error (and stack trace to log). Change-Id: Id17a1e5bff9aec251aa6f7fe6ff4e96cd2a01564
This commit is contained in:
parent
b37b7187ae
commit
5349d8823d
4 changed files with 99 additions and 0 deletions
|
@ -0,0 +1,56 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Kichwa Coders Canada Inc. and others. All rights reserved.
|
||||
* This program and the accompanying materials are made available under the terms
|
||||
* of the Eclipse Public License 2.0 which accompanies this distribution, and is
|
||||
* available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.terminal.view.ui.internal.dialogs;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanelContainer;
|
||||
import org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel;
|
||||
|
||||
/**
|
||||
* An empty configuration panel implementation.
|
||||
*/
|
||||
public class ErrorSettingsPanel extends AbstractConfigurationPanel {
|
||||
|
||||
private String errorMessage;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param container The configuration panel container or <code>null</code>.
|
||||
*/
|
||||
public ErrorSettingsPanel(IConfigurationPanelContainer container, String errorMessage) {
|
||||
super(container);
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupPanel(Composite parent) {
|
||||
Composite panel = new Composite(parent, SWT.NONE);
|
||||
panel.setLayout(new GridLayout());
|
||||
panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
|
||||
panel.setBackground(parent.getBackground());
|
||||
|
||||
if (errorMessage != null) {
|
||||
Label label = new Label(panel, SWT.NONE);
|
||||
label.setText(errorMessage);
|
||||
}
|
||||
|
||||
setControl(panel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -39,14 +39,18 @@ import org.eclipse.swt.widgets.Control;
|
|||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
|
||||
import org.eclipse.tm.terminal.view.core.interfaces.ITerminalService.Done;
|
||||
import org.eclipse.tm.terminal.view.core.interfaces.constants.ITerminalsConnectorConstants;
|
||||
import org.eclipse.tm.terminal.view.ui.activator.UIPlugin;
|
||||
import org.eclipse.tm.terminal.view.ui.controls.ConfigurationPanelControl;
|
||||
import org.eclipse.tm.terminal.view.ui.help.IContextHelpIds;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanel;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanelContainer;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.IExternalExecutablesProperties;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.tracing.ITraceIds;
|
||||
import org.eclipse.tm.terminal.view.ui.launcher.AbstractLauncherDelegate;
|
||||
import org.eclipse.tm.terminal.view.ui.launcher.LauncherDelegateManager;
|
||||
import org.eclipse.tm.terminal.view.ui.local.showin.ExternalExecutablesManager;
|
||||
import org.eclipse.tm.terminal.view.ui.nls.Messages;
|
||||
|
@ -57,6 +61,12 @@ import org.eclipse.ui.PlatformUI;
|
|||
* Launch terminal settings dialog implementation.
|
||||
*/
|
||||
public class LaunchTerminalSettingsDialog extends TrayDialog {
|
||||
/**
|
||||
* Special label for terminal (not shown to user) when there are no terminal
|
||||
* connectors installed.
|
||||
*/
|
||||
private static final String NO_CONNECTORS_LABEL = "none"; //$NON-NLS-1$
|
||||
|
||||
private String contextHelpId = null;
|
||||
|
||||
// The parent selection
|
||||
|
@ -496,6 +506,37 @@ public class LaunchTerminalSettingsDialog extends TrayDialog {
|
|||
|
||||
}
|
||||
|
||||
if (items.isEmpty()) {
|
||||
// No connectors at all installed - display warning to user.
|
||||
ILauncherDelegate noDelegate = new AbstractLauncherDelegate() {
|
||||
|
||||
@Override
|
||||
public boolean needsUserConfiguration() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigurationPanel getPanel(IConfigurationPanelContainer container) {
|
||||
return new ErrorSettingsPanel(container,
|
||||
Messages.LaunchTerminalSettingsDialog_error_no_terminal_connectors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Map<String, Object> properties, Done done) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITerminalConnector createTerminalConnector(Map<String, Object> properties) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
label2delegate.put(NO_CONNECTORS_LABEL, noDelegate);
|
||||
items.add(NO_CONNECTORS_LABEL);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,6 +106,7 @@ public class Messages extends NLS {
|
|||
|
||||
public static String LaunchTerminalSettingsDialog_error_title;
|
||||
public static String LaunchTerminalSettingsDialog_error_invalidSettings;
|
||||
public static String LaunchTerminalSettingsDialog_error_no_terminal_connectors;
|
||||
public static String LaunchTerminalSettingsDialog_error_unknownReason;
|
||||
|
||||
public static String EncodingSelectionDialog_title;
|
||||
|
|
|
@ -64,6 +64,7 @@ LaunchTerminalSettingsDialog_error_title=Terminal Settings
|
|||
LaunchTerminalSettingsDialog_error_invalidSettings=The specified settings are invalid\n\n\
|
||||
{0}\n\n\
|
||||
Please review and specify valid settings. Or cancel the settings dialog to abort.
|
||||
LaunchTerminalSettingsDialog_error_no_terminal_connectors=There are no types of terminals installed. Please install a terminal connector
|
||||
LaunchTerminalSettingsDialog_error_unknownReason=Cannot determine specifically which setting is invalid.
|
||||
|
||||
EncodingSelectionDialog_title=Encoding
|
||||
|
|
Loading…
Add table
Reference in a new issue