Skip to content

Commit

Permalink
Bug 341721: Add context menu item to change terminal name
Browse files Browse the repository at this point in the history
Change-Id: Idd41b58ad4f052c32d6a9c57303f1b9ef05aff7c
  • Loading branch information
jonahgraham committed Mar 1, 2021
1 parent fe00320 commit 6874b7e
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,9 @@ public interface ITerminalViewControl {
* @since 4.1
*/
void removeMouseListener(ITerminalMouseListener listener);

/**
* @since 5.1
*/
void setTerminalTitle(String newTitle);
}
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,9 @@ public static String getString(String key) {
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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
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;
Expand Down Expand Up @@ -303,6 +304,14 @@ protected ITerminalViewControl getTarget() {
return getActiveTerminalViewControl();
}
});

// change the name of the terminal
add(new RenameTerminalAction(getParentView().getAdapter(TabFolderManager.class)) {
@Override
protected ITerminalViewControl getTarget() {
return getActiveTerminalViewControl();
}
});
}

/**
Expand Down

0 comments on commit 6874b7e

Please sign in to comment.