diff options
16 files changed, 501 insertions, 175 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/build.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/build.properties index e8d9fa711..fc5711e2d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/build.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/build.properties @@ -1,17 +1,18 @@ -###############################################################################
-# Copyright (c) 2012 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
-###############################################################################
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.properties,\
- plugin.xml,\
- about.html
-src.includes = schema/
+############################################################################### +# Copyright (c) 2012 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 +############################################################################### +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.properties,\ + plugin.xml,\ + about.html,\ + icons/ +src.includes = schema/ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/icons/clcl16/command_input_field.gif b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/icons/clcl16/command_input_field.gif Binary files differnew file mode 100644 index 000000000..9e3a547c1 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/icons/clcl16/command_input_field.gif diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/icons/dlcl16/command_input_field.gif b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/icons/dlcl16/command_input_field.gif Binary files differnew file mode 100644 index 000000000..f538ca707 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/icons/dlcl16/command_input_field.gif diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/icons/elcl16/command_input_field.gif b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/icons/elcl16/command_input_field.gif Binary files differnew file mode 100644 index 000000000..f538ca707 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/icons/elcl16/command_input_field.gif diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/actions/TabScrollLockAction.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/actions/TabScrollLockAction.java index 4537d2147..571eb8da3 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/actions/TabScrollLockAction.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/actions/TabScrollLockAction.java @@ -15,6 +15,7 @@ import org.eclipse.tcf.te.ui.terminals.interfaces.ImageConsts; import org.eclipse.tcf.te.ui.terminals.nls.Messages; import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; import org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; /** * Terminal console tab scroll lock action. @@ -53,6 +54,6 @@ public class TabScrollLockAction extends AbstractTerminalAction { */ @Override public void updateAction(boolean aboutToShow) { - setEnabled(getTarget() != null && aboutToShow); + setEnabled(aboutToShow && getTarget() != null && getTarget().getState() == TerminalState.CONNECTED); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/actions/ToggleCommandFieldAction.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/actions/ToggleCommandFieldAction.java new file mode 100644 index 000000000..d2eb36b2c --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/actions/ToggleCommandFieldAction.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2012 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.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.tcf.te.ui.terminals.activator.UIPlugin; +import org.eclipse.tcf.te.ui.terminals.interfaces.ITerminalsView; +import org.eclipse.tcf.te.ui.terminals.interfaces.ImageConsts; +import org.eclipse.tcf.te.ui.terminals.nls.Messages; +import org.eclipse.tcf.te.ui.terminals.tabs.TabCommandFieldHandler; +import org.eclipse.tcf.te.ui.terminals.tabs.TabFolderManager; +import org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; + +/** + * Toggle command input field. + */ +@SuppressWarnings("restriction") +public class ToggleCommandFieldAction extends AbstractTerminalAction { + private ITerminalsView view = null; + + /** + * Constructor. + */ + public ToggleCommandFieldAction(ITerminalsView view) { + super(null, ToggleCommandFieldAction.class.getName(), IAction.AS_CHECK_BOX); + + this.view = view; + setupAction(Messages.ToggleCommandFieldAction_menu, Messages.ToggleCommandFieldAction_toolTip, + UIPlugin.getImageDescriptor(ImageConsts.ACTION_ToggleCommandField_Hover), + UIPlugin.getImageDescriptor(ImageConsts.ACTION_ToggleCommandField_Enabled), + UIPlugin.getImageDescriptor(ImageConsts.ACTION_ToggleCommandField_Disabled), true); + + TabCommandFieldHandler handler = getCommandFieldHandler(); + setChecked(handler != null && handler.hasCommandInputField()); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.IAction#run() + */ + @Override + public void run() { + TabCommandFieldHandler handler = getCommandFieldHandler(); + if (handler != null) { + handler.setCommandInputField(!handler.hasCommandInputField()); + } + setChecked(handler != null && handler.hasCommandInputField()); + } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction#updateAction(boolean) + */ + @Override + public void updateAction(boolean aboutToShow) { + setEnabled(aboutToShow && getCommandFieldHandler() != null + && getTarget() != null && getTarget().getState() == TerminalState.CONNECTED); + } + + /** + * Returns the command input field handler for the active tab. + * + * @return The command input field handler or <code>null</code>. + */ + protected TabCommandFieldHandler getCommandFieldHandler() { + TabCommandFieldHandler handler = null; + // Get the active tab item from the tab folder manager + TabFolderManager manager = (TabFolderManager)view.getAdapter(TabFolderManager.class); + if (manager != null) { + // If we have the active tab item, we can get the active terminal control + CTabItem activeTabItem = manager.getActiveTabItem(); + if (activeTabItem != null && !activeTabItem.isDisposed()) { + handler = manager.getTabCommandFieldHandler(activeTabItem); + } + } + return handler; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/activator/UIPlugin.java index 38d394c52..3466ecd99 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/activator/UIPlugin.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/activator/UIPlugin.java @@ -1,152 +1,159 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 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
- * Max Weninger (Wind River) - [361363] [TERMINALS] Implement "Pin&Clone" for the "Terminals" view
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.terminals.activator;
-
-import java.net.URL;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
-import org.eclipse.tcf.te.runtime.tracing.TraceHandler;
-import org.eclipse.tcf.te.ui.terminals.interfaces.ImageConsts;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class UIPlugin extends AbstractUIPlugin {
- // The shared instance
- private static UIPlugin plugin;
- // The scoped preferences instance
- private static volatile ScopedEclipsePreferences scopedPreferences;
- // The trace handler instance
- private static volatile TraceHandler traceHandler;
-
- /**
- * The constructor
- */
- public UIPlugin() {
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static UIPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Convenience method which returns the unique identifier of this plugin.
- */
- public static String getUniqueIdentifier() {
- if (getDefault() != null && getDefault().getBundle() != null) {
- return getDefault().getBundle().getSymbolicName();
- }
- return "org.eclipse.tcf.te.ui.terminals"; //$NON-NLS-1$
- }
-
- /**
- * Return the scoped preferences for this plugin.
- */
- public static ScopedEclipsePreferences getScopedPreferences() {
- if (scopedPreferences == null) {
- scopedPreferences = new ScopedEclipsePreferences(getUniqueIdentifier());
- }
- return scopedPreferences;
- }
-
- /**
- * Returns the bundles trace handler.
- *
- * @return The bundles trace handler.
- */
- public static TraceHandler getTraceHandler() {
- if (traceHandler == null) {
- traceHandler = new TraceHandler(getUniqueIdentifier());
- }
- return traceHandler;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- scopedPreferences = null;
- traceHandler = null;
- super.stop(context);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry)
- */
- @Override
- protected void initializeImageRegistry(ImageRegistry registry) {
- Bundle bundle = Platform.getBundle("org.eclipse.ui.console"); //$NON-NLS-1$
- if (bundle != null) {
- URL url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_EVIEW + "console_view.gif"); //$NON-NLS-1$ //$NON-NLS-2$
- registry.put(ImageConsts.VIEW_Terminals, ImageDescriptor.createFromURL(url));
-
- url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_CLCL + "lock_co.gif"); //$NON-NLS-1$ //$NON-NLS-2$
- registry.put(ImageConsts.ACTION_ScrollLock_Hover, ImageDescriptor.createFromURL(url));
- url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_ELCL + "lock_co.gif"); //$NON-NLS-1$ //$NON-NLS-2$
- registry.put(ImageConsts.ACTION_ScrollLock_Enabled, ImageDescriptor.createFromURL(url));
- url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_DLCL + "lock_co.gif"); //$NON-NLS-1$ //$NON-NLS-2$
- registry.put(ImageConsts.ACTION_ScrollLock_Disabled, ImageDescriptor.createFromURL(url));
-
- url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_CLCL + "pin.gif"); //$NON-NLS-1$ //$NON-NLS-2$
- registry.put(ImageConsts.ACTION_PinTerminal_Hover, ImageDescriptor.createFromURL(url));
- url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_ELCL + "pin.gif"); //$NON-NLS-1$ //$NON-NLS-2$
- registry.put(ImageConsts.ACTION_PinTerminal_Enabled, ImageDescriptor.createFromURL(url));
- url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_DLCL + "pin.gif"); //$NON-NLS-1$ //$NON-NLS-2$
- registry.put(ImageConsts.ACTION_PinTerminal_Disabled, ImageDescriptor.createFromURL(url));
-
- }
- }
-
- /**
- * Loads the image registered under the specified key from the image
- * registry and returns the <code>Image</code> object instance.
- *
- * @param key The key the image is registered with.
- * @return The <code>Image</code> object instance or <code>null</code>.
- */
- public static Image getImage(String key) {
- return getDefault().getImageRegistry().get(key);
- }
-
- /**
- * Loads the image registered under the specified key from the image
- * registry and returns the <code>ImageDescriptor</code> object instance.
- *
- * @param key The key the image is registered with.
- * @return The <code>ImageDescriptor</code> object instance or <code>null</code>.
- */
- public static ImageDescriptor getImageDescriptor(String key) {
- return getDefault().getImageRegistry().getDescriptor(key);
- }
-}
+/******************************************************************************* + * Copyright (c) 2011, 2012 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 + * Max Weninger (Wind River) - [361363] [TERMINALS] Implement "Pin&Clone" for the "Terminals" view + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.activator; + +import java.net.URL; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.swt.graphics.Image; +import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences; +import org.eclipse.tcf.te.runtime.tracing.TraceHandler; +import org.eclipse.tcf.te.ui.terminals.interfaces.ImageConsts; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class UIPlugin extends AbstractUIPlugin { + // The shared instance + private static UIPlugin plugin; + // The scoped preferences instance + private static volatile ScopedEclipsePreferences scopedPreferences; + // The trace handler instance + private static volatile TraceHandler traceHandler; + + /** + * The constructor + */ + public UIPlugin() { + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static UIPlugin getDefault() { + return plugin; + } + + /** + * Convenience method which returns the unique identifier of this plugin. + */ + public static String getUniqueIdentifier() { + if (getDefault() != null && getDefault().getBundle() != null) { + return getDefault().getBundle().getSymbolicName(); + } + return "org.eclipse.tcf.te.ui.terminals"; //$NON-NLS-1$ + } + + /** + * Return the scoped preferences for this plugin. + */ + public static ScopedEclipsePreferences getScopedPreferences() { + if (scopedPreferences == null) { + scopedPreferences = new ScopedEclipsePreferences(getUniqueIdentifier()); + } + return scopedPreferences; + } + + /** + * Returns the bundles trace handler. + * + * @return The bundles trace handler. + */ + public static TraceHandler getTraceHandler() { + if (traceHandler == null) { + traceHandler = new TraceHandler(getUniqueIdentifier()); + } + return traceHandler; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + scopedPreferences = null; + traceHandler = null; + super.stop(context); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry) + */ + @Override + protected void initializeImageRegistry(ImageRegistry registry) { + Bundle bundle = Platform.getBundle("org.eclipse.ui.console"); //$NON-NLS-1$ + if (bundle != null) { + URL url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_EVIEW + "console_view.gif"); //$NON-NLS-1$ //$NON-NLS-2$ + registry.put(ImageConsts.VIEW_Terminals, ImageDescriptor.createFromURL(url)); + + url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_CLCL + "lock_co.gif"); //$NON-NLS-1$ //$NON-NLS-2$ + registry.put(ImageConsts.ACTION_ScrollLock_Hover, ImageDescriptor.createFromURL(url)); + url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_ELCL + "lock_co.gif"); //$NON-NLS-1$ //$NON-NLS-2$ + registry.put(ImageConsts.ACTION_ScrollLock_Enabled, ImageDescriptor.createFromURL(url)); + url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_DLCL + "lock_co.gif"); //$NON-NLS-1$ //$NON-NLS-2$ + registry.put(ImageConsts.ACTION_ScrollLock_Disabled, ImageDescriptor.createFromURL(url)); + + url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_CLCL + "pin.gif"); //$NON-NLS-1$ //$NON-NLS-2$ + registry.put(ImageConsts.ACTION_PinTerminal_Hover, ImageDescriptor.createFromURL(url)); + url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_ELCL + "pin.gif"); //$NON-NLS-1$ //$NON-NLS-2$ + registry.put(ImageConsts.ACTION_PinTerminal_Enabled, ImageDescriptor.createFromURL(url)); + url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_DLCL + "pin.gif"); //$NON-NLS-1$ //$NON-NLS-2$ + registry.put(ImageConsts.ACTION_PinTerminal_Disabled, ImageDescriptor.createFromURL(url)); + } + + bundle = getBundle(); + URL url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_CLCL + "command_input_field.gif"); //$NON-NLS-1$ + registry.put(ImageConsts.ACTION_ToggleCommandField_Hover, ImageDescriptor.createFromURL(url)); + url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_ELCL + "command_input_field.gif"); //$NON-NLS-1$ + registry.put(ImageConsts.ACTION_ToggleCommandField_Enabled, ImageDescriptor.createFromURL(url)); + url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_DLCL + "command_input_field.gif"); //$NON-NLS-1$ + registry.put(ImageConsts.ACTION_ToggleCommandField_Disabled, ImageDescriptor.createFromURL(url)); + } + + /** + * Loads the image registered under the specified key from the image + * registry and returns the <code>Image</code> object instance. + * + * @param key The key the image is registered with. + * @return The <code>Image</code> object instance or <code>null</code>. + */ + public static Image getImage(String key) { + return getDefault().getImageRegistry().get(key); + } + + /** + * Loads the image registered under the specified key from the image + * registry and returns the <code>ImageDescriptor</code> object instance. + * + * @param key The key the image is registered with. + * @return The <code>ImageDescriptor</code> object instance or <code>null</code>. + */ + public static ImageDescriptor getImageDescriptor(String key) { + return getDefault().getImageRegistry().getDescriptor(key); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ImageConsts.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ImageConsts.java index cafce54c4..1a4ee78a5 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ImageConsts.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ImageConsts.java @@ -79,4 +79,18 @@ public interface ImageConsts { */ public static final String ACTION_PinTerminal_Hover = "PinTerminalAction_hover"; //$NON-NLS-1$ + /** + * The key to access the toggle command field action image (enabled). + */ + public static final String ACTION_ToggleCommandField_Enabled = "ToggleCommandField_enabled"; //$NON-NLS-1$ + + /** + * The key to access the toggle command field action image (disabled). + */ + public static final String ACTION_ToggleCommandField_Disabled = "ToggleCommandField_disabled"; //$NON-NLS-1$ + + /** + * The key to access the toggle command field action image (hover). + */ + public static final String ACTION_ToggleCommandField_Hover = "ToggleCommandField_hover"; //$NON-NLS-1$ } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/nls/Messages.java index 14213268a..86351120e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/nls/Messages.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/nls/Messages.java @@ -46,6 +46,9 @@ public class Messages extends NLS { public static String PinTerminalAction_menu; public static String PinTerminalAction_toolTip; + public static String ToggleCommandFieldAction_menu; + public static String ToggleCommandFieldAction_toolTip; + public static String ProcessSettingsPage_dialogTitle; public static String ProcessSettingsPage_processImagePathSelectorControl_label; public static String ProcessSettingsPage_processImagePathSelectorControl_button; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/nls/Messages.properties index c91b0b7eb..faa37da97 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/nls/Messages.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/nls/Messages.properties @@ -24,6 +24,9 @@ TabTerminalListener_consoleTerminated=<terminated> {0} PinTerminalAction_menu=Pin PinTerminalAction_toolTip=Pin the Terminal View +ToggleCommandFieldAction_menu=Toggle Command Input Field +ToggleCommandFieldAction_toolTip=Toggle Command Input Field + ProcessSettingsPage_dialogTitle=Select Process Image ProcessSettingsPage_processImagePathSelectorControl_label=Image Path: ProcessSettingsPage_processImagePathSelectorControl_button=Browse diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabCommandFieldHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabCommandFieldHandler.java new file mode 100644 index 000000000..ccccc93d1 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabCommandFieldHandler.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2012 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.tabs; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.tcf.te.runtime.interfaces.IDisposable; +import org.eclipse.tm.internal.terminal.control.CommandInputFieldWithHistory; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; + +/** + * Tab command input field handler implementation. + */ +@SuppressWarnings("restriction") +public class TabCommandFieldHandler implements IDisposable, IAdaptable { + // Reference to the parent tab folder manager + private final TabFolderManager tabFolderManager; + // Reference to the associated tab + private final CTabItem item; + + // Reference to the command input field + private CommandInputFieldWithHistory field; + // The command field history + private String history; + + /** + * Constructor. + * + * @param tabFolderManager The parent tab folder manager. Must not be <code>null</code> + * @param item The associated tab item. Must not be <code>null</code>. + */ + public TabCommandFieldHandler(TabFolderManager tabFolderManager, CTabItem item) { + Assert.isNotNull(tabFolderManager); + this.tabFolderManager = tabFolderManager; + Assert.isNotNull(item); + this.item = item; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.interfaces.IDisposable#dispose() + */ + @Override + public void dispose() { + field = null; + history = null; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) + */ + @Override + public Object getAdapter(Class adapter) { + if (TabFolderManager.class.equals(adapter)) { + return tabFolderManager; + } + if (CTabItem.class.equals(adapter)) { + return item; + } + return null; + } + + /** + * Returns if or if not the associated tab item has the command input field enabled. + * + * @return <code>True</code> if the command input field is enabled, <code>false</code> otherwise. + */ + public boolean hasCommandInputField() { + return field != null; + } + + /** + * Set the command input field on or off. + * + * @param on <code>True</code> for on, <code>false</code> for off. + */ + public void setCommandInputField(boolean on) { + // save the old history + if (field != null) { + history = field.getHistory(); + field = null; + } + + if (on) { + field = new CommandInputFieldWithHistory(100); + field.setHistory(history); + } + + // Apply to the terminal control + Assert.isTrue(!item.isDisposed()); + ITerminalViewControl terminal = (ITerminalViewControl)item.getData(); + if (terminal != null) terminal.setCommandInputField(field); + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabDisposeListener.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabDisposeListener.java index 9aa9de1fa..123813713 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabDisposeListener.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabDisposeListener.java @@ -53,6 +53,8 @@ public class TabDisposeListener implements DisposeListener { // Get the terminal control (if any) from the tab item Object candidate = ((CTabItem)e.getSource()).getData(); if (candidate instanceof ITerminalViewControl) ((ITerminalViewControl)candidate).disposeTerminal(); + // Dispose the command input field handler + parentTabFolderManager.disposeTabCommandFieldHandler((CTabItem)e.getSource()); // If all items got removed, we have to switch back to the empty page control if (parentTabFolderManager.getTabFolder() != null && parentTabFolderManager.getTabFolder().getItemCount() == 0) { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java index f43ba5e8d..60e94d68d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java @@ -12,8 +12,10 @@ package org.eclipse.tcf.te.ui.terminals.tabs; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.EventObject; +import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.PlatformObject; @@ -72,6 +74,11 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid private final List<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>(); /** + * Map of tab command input field handler per tab item + */ + private final Map<CTabItem, TabCommandFieldHandler> commandFieldHandler = new HashMap<CTabItem, TabCommandFieldHandler>(); + + /** * The terminal control selection listener implementation. */ private class TerminalControlSelectionListener implements DisposeListener, MouseListener { @@ -280,6 +287,11 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid if (broadcastedSelectionChangedEventListener != null) { EventManager.getInstance().removeEventListener(broadcastedSelectionChangedEventListener); } + // Dispose the tab command field handler + for (TabCommandFieldHandler handler : commandFieldHandler.values()) { + handler.dispose(); + } + commandFieldHandler.clear(); } /** @@ -326,7 +338,7 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid tabFolder.getParent().layout(true); // Create the terminal control - ITerminalViewControl terminal = TerminalViewControlFactory.makeControl(doCreateTerminalTabTerminalListener(item), composite, new ITerminalConnector[] { connector }, true); + ITerminalViewControl terminal = TerminalViewControlFactory.makeControl(doCreateTerminalTabTerminalListener(this, item), composite, new ITerminalConnector[] { connector }, true); // Add the "selection" listener to the terminal control new TerminalControlSelectionListener(terminal); // Configure the terminal encoding @@ -527,12 +539,14 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid /** * Creates a new terminal console tab terminal listener instance. * + * @param tabFolderManager The tab folder manager. Must not be <code>null</code>. * @param item The tab item. Must not be <code>null</code>. + * * @return The terminal listener instance. */ - protected ITerminalListener doCreateTerminalTabTerminalListener(CTabItem item) { + protected ITerminalListener doCreateTerminalTabTerminalListener(TabFolderManager tabFolderManager, CTabItem item) { Assert.isNotNull(item); - return new TabTerminalListener(item); + return new TabTerminalListener(tabFolderManager, item); } /** @@ -685,6 +699,37 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid return false; } + /** + * Returns the command input field handler for the given tab item. + * + * @param item The tab item or <code>null</code>. + * @return The command input field handler or <code>null</code>. + */ + public final TabCommandFieldHandler getTabCommandFieldHandler(CTabItem item) { + // Null items or disposed items cannot be matched + if (item == null || item.isDisposed()) return null; + + TabCommandFieldHandler handler = commandFieldHandler.get(item); + if (handler == null) { + handler = new TabCommandFieldHandler(this, item); + commandFieldHandler.put(item, handler); + } + return handler; + } + + /** + * Dispose the command input field handler for the given tab item. + * + * @param item The tab item or <code>null</code>. + */ + protected void disposeTabCommandFieldHandler(CTabItem item) { + // Null items or disposed items cannot be matched + if (item == null || item.isDisposed()) return; + + TabCommandFieldHandler handler = commandFieldHandler.remove(item); + if (handler != null) handler.dispose(); + } + /* (non-Javadoc) * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) */ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderMenuHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderMenuHandler.java index cf2fe3ba1..eb1c4a3e5 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderMenuHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderMenuHandler.java @@ -22,6 +22,7 @@ import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.widgets.Menu; import org.eclipse.tcf.te.ui.terminals.actions.TabScrollLockAction; +import org.eclipse.tcf.te.ui.terminals.actions.ToggleCommandFieldAction; import org.eclipse.tcf.te.ui.terminals.interfaces.ITerminalsView; import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; import org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction; @@ -29,6 +30,7 @@ import org.eclipse.tm.internal.terminal.control.actions.TerminalActionClearAll; import org.eclipse.tm.internal.terminal.control.actions.TerminalActionCopy; import org.eclipse.tm.internal.terminal.control.actions.TerminalActionPaste; import org.eclipse.tm.internal.terminal.control.actions.TerminalActionSelectAll; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; import org.eclipse.ui.IWorkbenchActionConstants; /** @@ -191,6 +193,17 @@ public class TabFolderMenuHandler extends PlatformObject { protected ITerminalViewControl getTarget() { return getActiveTerminalViewControl(); } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.control.actions.TerminalActionPaste#updateAction(boolean) + */ + @Override + public void updateAction(boolean aboutToShow) { + super.updateAction(aboutToShow); + if (getTarget() != null && getTarget().getState() != TerminalState.CONNECTED) { + setEnabled(false); + } + } }); // Create and add the select all action @@ -204,6 +217,17 @@ public class TabFolderMenuHandler extends PlatformObject { } }); + // Create and add the toggle command input field action + add (new ToggleCommandFieldAction(getParentView()) { + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction#getTarget() + */ + @Override + protected ITerminalViewControl getTarget() { + return getActiveTerminalViewControl(); + } + }); + // Create and add the scroll lock action add (new TabScrollLockAction() { /* (non-Javadoc) diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderToolbarHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderToolbarHandler.java index 6fba96726..50eebb2c7 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderToolbarHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderToolbarHandler.java @@ -25,12 +25,14 @@ import org.eclipse.swt.custom.CTabItem; import org.eclipse.tcf.te.ui.terminals.actions.AbstractAction; import org.eclipse.tcf.te.ui.terminals.actions.PinTerminalAction; import org.eclipse.tcf.te.ui.terminals.actions.TabScrollLockAction; +import org.eclipse.tcf.te.ui.terminals.actions.ToggleCommandFieldAction; import org.eclipse.tcf.te.ui.terminals.interfaces.ITerminalsView; import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; import org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction; import org.eclipse.tm.internal.terminal.control.actions.TerminalActionClearAll; import org.eclipse.tm.internal.terminal.control.actions.TerminalActionCopy; import org.eclipse.tm.internal.terminal.control.actions.TerminalActionPaste; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IWorkbenchActionConstants; @@ -236,6 +238,28 @@ public class TabFolderToolbarHandler extends PlatformObject { protected ITerminalViewControl getTarget() { return getActiveTerminalViewControl(); } + + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.control.actions.TerminalActionPaste#updateAction(boolean) + */ + @Override + public void updateAction(boolean aboutToShow) { + super.updateAction(aboutToShow); + if (getTarget() != null && getTarget().getState() != TerminalState.CONNECTED) { + setEnabled(false); + } + } + }); + + // Create and add the toggle command input field action + add (new ToggleCommandFieldAction(getParentView()) { + /* (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction#getTarget() + */ + @Override + protected ITerminalViewControl getTarget() { + return getActiveTerminalViewControl(); + } }); // Create and add the pin view action diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabTerminalListener.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabTerminalListener.java index 0c838c8d2..366f40b12 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabTerminalListener.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabTerminalListener.java @@ -12,6 +12,7 @@ package org.eclipse.tcf.te.ui.terminals.tabs; import java.util.regex.Pattern; import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.widgets.Display; @@ -24,15 +25,19 @@ import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; */ @SuppressWarnings("restriction") public class TabTerminalListener implements ITerminalListener { + /* default */ final TabFolderManager tabFolderManager; private final CTabItem tabItem; /** * Constructor. * + * @param tabFolderManager The parent tab folder manager. Must not be <code>null</code>. * @param tabItem The parent tab item. Must not be <code>null</code>. */ - public TabTerminalListener(CTabItem tabItem) { + public TabTerminalListener(TabFolderManager tabFolderManager, CTabItem tabItem) { super(); + Assert.isNotNull(tabFolderManager); + this.tabFolderManager = tabFolderManager; Assert.isNotNull(tabItem); this.tabItem = tabItem; } @@ -55,12 +60,22 @@ public class TabTerminalListener implements ITerminalListener { final CTabItem item = getTabItem(); if (item == null || item.isDisposed()) return; - // Update the tab item title + // Run asynchronously in the display thread item.getDisplay().asyncExec(new Runnable() { @Override public void run() { + // Update the tab item title String newTitle = getTerminalConsoleTabTitle(state); if (newTitle != null) item.setText(newTitle); + + // Turn off the command field (if necessary) + TabCommandFieldHandler handler = tabFolderManager.getTabCommandFieldHandler(item); + if (handler != null && handler.hasCommandInputField()) { + handler.setCommandInputField(false); + ISelectionProvider provider = tabFolderManager.getParentView().getViewSite().getSelectionProvider(); + Assert.isNotNull(provider); + provider.setSelection(provider.getSelection()); + } } }); } |