1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 573796: Warn user if not using UTF-8 on Windows

The PTY, in case of ConPTY, operates always in UTF-8. This is suggested
back to the user with a decorated combo if they try to change the default.

Change-Id: Iaf4c13e256ea7ee3469eecab4a0ec3df1ceb19a4
This commit is contained in:
Jonah Graham 2021-05-27 01:31:51 -04:00
parent 481f08beb4
commit 27f6637d3f
6 changed files with 74 additions and 2 deletions

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.tm.terminal.connector.local;singleton:=true
Bundle-Version: 4.7.100.qualifier
Bundle-Version: 4.7.200.qualifier
Bundle-Activator: org.eclipse.tm.terminal.connector.local.activator.UIPlugin
Bundle-Vendor: %providerName
Import-Package: org.eclipse.cdt.utils.pty;mandatory:=native

View file

@ -16,10 +16,13 @@ import java.util.Map;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
@ -83,6 +86,20 @@ public class LocalWizardConfigurationPanel extends AbstractExtendedConfiguration
setControl(panel);
}
@Override
protected void decorateEncoding(ControlDecoration encodingComboDecorator, String encoding) {
if ((Platform.OS_MACOSX.equals(Platform.getOS()) || Platform.OS_WIN32.equals(Platform.getOS()))
&& !"UTF-8".equals(encoding)) { //$NON-NLS-1$
Image decorationImage = FieldDecorationRegistry.getDefault()
.getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage();
encodingComboDecorator.setImage(decorationImage);
encodingComboDecorator.setDescriptionText(Messages.LocalWizardConfigurationPanel_encoding_does_not_match);
encodingComboDecorator.show();
} else {
super.decorateEncoding(encodingComboDecorator, encoding);
}
}
@Override
public void setupData(Map<String, Object> data) {
if (data == null)

View file

@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2021 Kichwa Coders Canada Inc. and others.
*
* 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.connector.local.controls;
import org.eclipse.osgi.util.NLS;
/**
* @noreference This class is not intended to be referenced by clients.
*/
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.tm.terminal.connector.local.controls.Messages"; //$NON-NLS-1$
public static String LocalWizardConfigurationPanel_encoding_does_not_match;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages() {
}
}

View file

@ -0,0 +1,10 @@
###############################################################################
# Copyright (c) 2021 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
###############################################################################
LocalWizardConfigurationPanel_encoding_does_not_match=The selected encoding does not match the terminal being connected to. Recommended encoding is UTF-8.

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.tm.terminal.view.ui;singleton:=true
Bundle-Version: 4.9.0.qualifier
Bundle-Version: 4.10.0.qualifier
Bundle-Activator: org.eclipse.tm.terminal.view.ui.activator.UIPlugin
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.core.expressions;bundle-version="3.4.400",

View file

@ -28,6 +28,7 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
@ -454,6 +455,7 @@ public abstract class AbstractExtendedConfigurationPanel extends AbstractConfigu
label.setText(Messages.AbstractConfigurationPanel_encoding);
encodingCombo = new Combo(panel, SWT.READ_ONLY);
ControlDecoration encodingComboDecorator = new ControlDecoration(encodingCombo, SWT.TOP | SWT.LEFT);
encodingCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
encodingCombo.addSelectionListener(new SelectionAdapter() {
@Override
@ -494,6 +496,8 @@ public abstract class AbstractExtendedConfigurationPanel extends AbstractConfigu
encodingCombo.select(encodingCombo.indexOf(lastSelectedEncoding));
}
}
decorateEncoding(encodingComboDecorator, encodingCombo.getText());
}
});
@ -506,6 +510,20 @@ public abstract class AbstractExtendedConfigurationPanel extends AbstractConfigu
}
}
/**
* Allow the encoding combo box to be decorated with a warning or similar in case user selects
* inappropriate encoding.
*
* @param encodingComboDecorator control decoration on the encoding combo box
* @param encoding the encoding the user has selected
* @since 4.10
*/
protected void decorateEncoding(ControlDecoration encodingComboDecorator, String encoding) {
// by default don't warn users
encodingComboDecorator.hide();
encodingComboDecorator.hideHover();
}
/**
* Fill the encoding combo.
*/