mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 341721: Add context menu item to change terminal name
Change-Id: Idd41b58ad4f052c32d6a9c57303f1b9ef05aff7c
This commit is contained in:
parent
fe00320854
commit
6874b7e013
5 changed files with 90 additions and 0 deletions
|
@ -166,4 +166,9 @@ public interface ITerminalViewControl {
|
|||
* @since 4.1
|
||||
*/
|
||||
void removeMouseListener(ITerminalMouseListener listener);
|
||||
|
||||
/**
|
||||
* @since 5.1
|
||||
*/
|
||||
void setTerminalTitle(String newTitle);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*******************************************************************************
|
||||
* 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.view.ui.actions;
|
||||
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.jface.dialogs.InputDialog;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
|
||||
import org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction;
|
||||
import org.eclipse.tm.terminal.view.ui.nls.Messages;
|
||||
import org.eclipse.tm.terminal.view.ui.tabs.TabFolderManager;
|
||||
|
||||
/**
|
||||
* @since 4.8
|
||||
*/
|
||||
public class RenameTerminalAction extends AbstractTerminalAction {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tabFolderManager The parent tab folder manager. Must not be <code>null</code>.
|
||||
*/
|
||||
public RenameTerminalAction(TabFolderManager tabFolderManager) {
|
||||
super(RenameTerminalAction.class.getName());
|
||||
|
||||
Assert.isNotNull(tabFolderManager);
|
||||
setupAction(Messages.RenameTerminalAction_menu, Messages.RenameTerminalAction_tooltip, (ImageDescriptor) null,
|
||||
(ImageDescriptor) null, (ImageDescriptor) null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ITerminalViewControl target = getTarget();
|
||||
if (target == null)
|
||||
return;
|
||||
InputDialog inputDialog = new InputDialog(target.getControl().getShell(), //
|
||||
Messages.RenameTerminalAction_inputdialog_title, //
|
||||
Messages.RenameTerminalAction_inputdialog_prompt, //
|
||||
Messages.RenameTerminalAction_inputdialog_defaulttext, //
|
||||
null);
|
||||
if (inputDialog.open() == Window.OK) {
|
||||
String value = inputDialog.getValue();
|
||||
if (value != null) {
|
||||
target.setTerminalTitle(value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAction(boolean aboutToShow) {
|
||||
setEnabled(aboutToShow && getTarget() != null);
|
||||
}
|
||||
|
||||
}
|
|
@ -158,4 +158,9 @@ public class Messages extends NLS {
|
|||
public static String ExternalExecutablesDialog_field_icon;
|
||||
public static String ExternalExecutablesDialog_field_translate;
|
||||
|
||||
public static String RenameTerminalAction_inputdialog_defaulttext;
|
||||
public static String RenameTerminalAction_inputdialog_prompt;
|
||||
public static String RenameTerminalAction_inputdialog_title;
|
||||
public static String RenameTerminalAction_tooltip;
|
||||
public static String RenameTerminalAction_menu;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,12 @@ SelectEncodingAction_tooltip=Switch the Encoding of the active Terminal
|
|||
InvertColorsAction_menu=Inverted colors
|
||||
InvertColorsAction_tooltip=Invert the colors of the active Terminal
|
||||
|
||||
RenameTerminalAction_inputdialog_defaulttext=
|
||||
RenameTerminalAction_inputdialog_prompt=Please enter a new name for the terminal
|
||||
RenameTerminalAction_inputdialog_title=New name for terminal
|
||||
RenameTerminalAction_menu=Rename Terminal
|
||||
RenameTerminalAction_tooltip=Update the display name of this terminal
|
||||
|
||||
ProcessSettingsPage_dialogTitle=Select Process Image
|
||||
ProcessSettingsPage_processImagePathSelectorControl_label=Image Path:
|
||||
ProcessSettingsPage_processImagePathSelectorControl_button=Browse
|
||||
|
|
|
@ -36,6 +36,7 @@ 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.tm.terminal.view.core.interfaces.constants.ITerminalsConnectorConstants;
|
||||
import org.eclipse.tm.terminal.view.ui.actions.RenameTerminalAction;
|
||||
import org.eclipse.tm.terminal.view.ui.actions.InvertColorsAction;
|
||||
import org.eclipse.tm.terminal.view.ui.actions.SelectEncodingAction;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.ITerminalsView;
|
||||
|
@ -303,6 +304,14 @@ public class TabFolderMenuHandler extends PlatformObject {
|
|||
return getActiveTerminalViewControl();
|
||||
}
|
||||
});
|
||||
|
||||
// change the name of the terminal
|
||||
add(new RenameTerminalAction(getParentView().getAdapter(TabFolderManager.class)) {
|
||||
@Override
|
||||
protected ITerminalViewControl getTarget() {
|
||||
return getActiveTerminalViewControl();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue