Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java6
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java41
3 files changed, 41 insertions, 8 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java
index 71bac4e32..26704b870 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation 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
@@ -30,6 +30,8 @@ public class LaunchConfigurationsMessages extends NLS {
public static String CommonTab_14;
public static String CommonTab_0;
public static String CommonTab_1;
+
+ public static String CommonTab_15;
public static String CommonTab_2;
public static String CommonTab_3;
public static String CommonTab_4;
@@ -169,8 +171,6 @@ public class LaunchConfigurationsMessages extends NLS {
public static String DebugModePromptStatusHandler_0;
public static String DebugModePromptStatusHandler_1;
- public static String CommonTab_No_Encoding_Selected;
-
static {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, LaunchConfigurationsMessages.class);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
index 50f294bfd..773f57d42 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
@@ -9,7 +9,6 @@
# IBM Corporation - initial API and implementation
###############################################################################
-CommonTab_No_Encoding_Selected=Console encoding not selected
CommonTab__Browse_6=&Browse...
CommonTab__Common_15=&Common
CommonTab_Display_in_favorites_menu__10=Display in favor&ites menu
@@ -25,6 +24,7 @@ CommonTab_13=Select a Resource:
CommonTab_14=Select a resource to redirect output to:
CommonTab_0=Save as
CommonTab_1=Encoding
+CommonTab_15=The selected encoding is not supported.
CommonTab_2=Defa&ult - inherited ({0})
CommonTab_3=Oth&er
CommonTab_4=Standard Input and Output
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java
index afa1b03e2..d4eadad7f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java
@@ -11,6 +11,8 @@
package org.eclipse.debug.ui;
+import java.nio.charset.Charset;
+import java.nio.charset.IllegalCharsetNameException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -53,6 +55,8 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleAdapter;
import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
@@ -384,7 +388,7 @@ public class CommonTab extends AbstractLaunchConfigurationTab {
fAltEncodingButton = createRadioButton(group, LaunchConfigurationsMessages.CommonTab_3);
fAltEncodingButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- fEncodingCombo = new Combo(group, SWT.READ_ONLY);
+ fEncodingCombo = new Combo(group, SWT.NONE);
fEncodingCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fEncodingCombo.setFont(parent.getFont());
List allEncodings = IDEEncoding.getIDEEncodings();
@@ -415,6 +419,33 @@ public class CommonTab extends AbstractLaunchConfigurationTab {
fAltEncodingButton.addSelectionListener(listener);
fDefaultEncodingButton.addSelectionListener(listener);
fEncodingCombo.addSelectionListener(listener);
+ fEncodingCombo.addKeyListener(new KeyAdapter() {
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent)
+ */
+ public void keyReleased(KeyEvent e) {
+ scheduleUpdateJob();
+ }
+ });
+ }
+
+ /**
+ * Returns whether or not the given encoding is valid.
+ *
+ * @param enc
+ * the encoding to validate
+ * @return <code>true</code> if the encoding is valid, <code>false</code>
+ * otherwise
+ */
+ private boolean isValidEncoding(String enc) {
+ try {
+ return Charset.isSupported(enc);
+ } catch (IllegalCharsetNameException e) {
+ // This is a valid exception
+ return false;
+ }
}
/**
@@ -751,8 +782,10 @@ public class CommonTab extends AbstractLaunchConfigurationTab {
private boolean validateEncoding() {
if (fAltEncodingButton.getSelection()) {
if (fEncodingCombo.getSelectionIndex() == -1) {
- setErrorMessage(LaunchConfigurationsMessages.CommonTab_No_Encoding_Selected);
- return false;
+ if (!isValidEncoding(fEncodingCombo.getText().trim())) {
+ setErrorMessage(LaunchConfigurationsMessages.CommonTab_15);
+ return false;
+ }
}
}
return true;
@@ -809,7 +842,7 @@ public class CommonTab extends AbstractLaunchConfigurationTab {
setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, configuration, fLaunchInBackgroundButton.getSelection(), true);
String encoding = null;
if(fAltEncodingButton.getSelection()) {
- encoding = fEncodingCombo.getText();
+ encoding = fEncodingCombo.getText().trim();
}
configuration.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, encoding);
boolean captureOutput = false;

Back to the top