1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 23:05:47 +02:00

Bug 436612 - Restore Terminal compatibility with Eclipse 3.4

- Restore Terminal "core" compatibility with Eclipse down to 3.4
- Correctly mark the terminal "local" dependency on Eclipse 3.6
This commit is contained in:
Martin Oberhuber 2014-06-04 19:09:17 +02:00
parent ee07ae74f0
commit 8293ee73c0
3 changed files with 25 additions and 6 deletions

View file

@ -9,7 +9,7 @@ Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.tm.terminal;bundle-version="[3.2.0,3.3.0)", Require-Bundle: org.eclipse.tm.terminal;bundle-version="[3.2.0,3.3.0)",
org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)", org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)",
org.eclipse.core.runtime, org.eclipse.core.runtime,
org.eclipse.debug.core, org.eclipse.debug.core;bundle-version="3.6",
org.eclipse.debug.ui, org.eclipse.debug.ui,
org.eclipse.jface, org.eclipse.jface,
org.eclipse.ui, org.eclipse.ui,

View file

@ -36,6 +36,7 @@
* Anton Leherbauer (Wind River) - [434294] Incorrect handling of function keys with modifiers * Anton Leherbauer (Wind River) - [434294] Incorrect handling of function keys with modifiers
* Martin Oberhuber (Wind River) - [434294] Add Mac bindings with COMMAND * Martin Oberhuber (Wind River) - [434294] Add Mac bindings with COMMAND
* Anton Leherbauer (Wind River) - [434749] UnhandledEventLoopException when copying to clipboard while the selection is empty * Anton Leherbauer (Wind River) - [434749] UnhandledEventLoopException when copying to clipboard while the selection is empty
* Martin Oberhuber (Wind River) - [436612] Restore Eclipse 3.4 compatibility by using Reflection
*******************************************************************************/ *******************************************************************************/
package org.eclipse.tm.internal.terminal.emulator; package org.eclipse.tm.internal.terminal.emulator;
@ -43,6 +44,7 @@ import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.net.SocketException; import java.net.SocketException;
import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.ExecutionException;
@ -1172,7 +1174,18 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
cmdEvent.widget = event.widget; cmdEvent.widget = event.widget;
cmdEvent.character = event.character; cmdEvent.character = event.character;
cmdEvent.keyCode = event.keyCode; cmdEvent.keyCode = event.keyCode;
cmdEvent.keyLocation = event.keyLocation; ////Bug - KeyEvent.keyLocation was introduced in Eclipse 3.6
////Use reflection for now to remain backward compatible down to Eclipse 3.4
//cmdEvent.keyLocation = event.keyLocation;
try {
Field f1 = event.getClass().getField("keyLocation"); //$NON-NLS-1$
Field f2 = cmdEvent.getClass().getField("keyLocation"); //$NON-NLS-1$
f2.set(cmdEvent, f1.get(event));
} catch(NoSuchFieldException nsfe) {
/* ignore, this is Eclipse 3.5 or earlier */
} catch(Throwable t) {
t.printStackTrace();
}
cmdEvent.stateMask = event.stateMask; cmdEvent.stateMask = event.stateMask;
event.doit = false; event.doit = false;
try { try {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2012 Wind River Systems, Inc. and others. * Copyright (c) 2006, 2014 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* Michael Scharf (Wind River) - initial API and implementation * Michael Scharf (Wind River) - initial API and implementation
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified * Martin Oberhuber (Wind River) - fixed copyright headers and beautified
* Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget
* Martin Oberhuber (Wind River) - [436612] Restore Eclipse 3.4 compatibility
*******************************************************************************/ *******************************************************************************/
package org.eclipse.tm.internal.terminal.preferences; package org.eclipse.tm.internal.terminal.preferences;
@ -24,7 +25,9 @@ public class TerminalPreferenceInitializer extends AbstractPreferenceInitializer
} }
public void initializeDefaultPreferences() { public void initializeDefaultPreferences() {
IEclipsePreferences defaultPrefs = DefaultScope.INSTANCE.getNode(TerminalPlugin.PLUGIN_ID); //DefaultScope.INSTANCE was only added in Eclipse 3.7 - we want to be compatible further back
//IEclipsePreferences defaultPrefs = DefaultScope.INSTANCE.getNode(TerminalPlugin.PLUGIN_ID);
IEclipsePreferences defaultPrefs = new DefaultScope().getNode(TerminalPlugin.PLUGIN_ID);
defaultPrefs.putBoolean(ITerminalConstants.PREF_INVERT_COLORS, ITerminalConstants.DEFAULT_INVERT_COLORS); defaultPrefs.putBoolean(ITerminalConstants.PREF_INVERT_COLORS, ITerminalConstants.DEFAULT_INVERT_COLORS);
defaultPrefs.putInt(ITerminalConstants.PREF_BUFFERLINES, ITerminalConstants.DEFAULT_BUFFERLINES); defaultPrefs.putInt(ITerminalConstants.PREF_BUFFERLINES, ITerminalConstants.DEFAULT_BUFFERLINES);
migrateTerminalPreferences(); migrateTerminalPreferences();
@ -35,10 +38,13 @@ public class TerminalPreferenceInitializer extends AbstractPreferenceInitializer
*/ */
public static void migrateTerminalPreferences() { public static void migrateTerminalPreferences() {
//InstanceScope.INSTANCE was only added in Eclipse 3.7 - we want to be compatible further back //InstanceScope.INSTANCE was only added in Eclipse 3.7 - we want to be compatible further back
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(TerminalPlugin.PLUGIN_ID); //IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(TerminalPlugin.PLUGIN_ID);
IEclipsePreferences prefs = new InstanceScope().getNode(TerminalPlugin.PLUGIN_ID);
if (!prefs.getBoolean(ITerminalConstants.PREF_HAS_MIGRATED, false)) { if (!prefs.getBoolean(ITerminalConstants.PREF_HAS_MIGRATED, false)) {
prefs.putBoolean(ITerminalConstants.PREF_HAS_MIGRATED, true); prefs.putBoolean(ITerminalConstants.PREF_HAS_MIGRATED, true);
PreferenceModifyListener.migrateTerminalPreferences(InstanceScope.INSTANCE.getNode("")); //$NON-NLS-1$ //InstanceScope.INSTANCE was only added in Eclipse 3.7 - we want to be compatible further back
//PreferenceModifyListener.migrateTerminalPreferences(InstanceScope.INSTANCE.getNode("")); //$NON-NLS-1$
PreferenceModifyListener.migrateTerminalPreferences(new InstanceScope().getNode("")); //$NON-NLS-1$
} }
} }