mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
Improve "New Terminal View" handling.
- Add a command to open the new terminal view. Allows to associate a short cut - Open the "Open Terminal" dialog on creating a new terminal view
This commit is contained in:
parent
0a79c61273
commit
1a1bcf774b
4 changed files with 81 additions and 5 deletions
|
@ -42,6 +42,8 @@ command.disconnect.name=Disconnect Terminal
|
||||||
command.disconnect.label=Disconnect
|
command.disconnect.label=Disconnect
|
||||||
command.disconnect.tooltip=Disconnect Terminal Connection
|
command.disconnect.tooltip=Disconnect Terminal Connection
|
||||||
|
|
||||||
|
command.newview.name=New Terminal View
|
||||||
|
|
||||||
menu.showIn.label = Show In
|
menu.showIn.label = Show In
|
||||||
menu.showIn.mnemonic=I
|
menu.showIn.mnemonic=I
|
||||||
|
|
||||||
|
|
|
@ -239,6 +239,12 @@
|
||||||
id="org.eclipse.tm.terminal.view.ui.command.disconnect"
|
id="org.eclipse.tm.terminal.view.ui.command.disconnect"
|
||||||
name="%command.disconnect.name">
|
name="%command.disconnect.name">
|
||||||
</command>
|
</command>
|
||||||
|
<command
|
||||||
|
categoryId="org.eclipse.tm.terminal.view.ui.commands.category"
|
||||||
|
helpContextId="org.eclipse.tm.terminal.view.ui.command_NewView"
|
||||||
|
id="org.eclipse.tm.terminal.view.ui.command.newview"
|
||||||
|
name="%command.newview.name">
|
||||||
|
</command>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<!-- Key bindings -->
|
<!-- Key bindings -->
|
||||||
|
@ -291,6 +297,15 @@
|
||||||
</activeWhen>
|
</activeWhen>
|
||||||
</handler>
|
</handler>
|
||||||
|
|
||||||
|
<handler
|
||||||
|
class="org.eclipse.tm.terminal.view.ui.internal.handler.NewTerminalViewHandler"
|
||||||
|
commandId="org.eclipse.tm.terminal.view.ui.command.newview">
|
||||||
|
<activeWhen>
|
||||||
|
<with variable="activePartId">
|
||||||
|
<equals value="org.eclipse.tm.terminal.view.ui.TerminalsView"/>
|
||||||
|
</with>
|
||||||
|
</activeWhen>
|
||||||
|
</handler>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<!-- Help Context contributions -->
|
<!-- Help Context contributions -->
|
||||||
|
|
|
@ -9,14 +9,21 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.terminal.view.ui.actions;
|
package org.eclipse.tm.terminal.view.ui.actions;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.Command;
|
||||||
|
import org.eclipse.core.commands.ParameterizedCommand;
|
||||||
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.jface.action.IAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
import org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction;
|
import org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction;
|
||||||
import org.eclipse.tm.terminal.view.ui.activator.UIPlugin;
|
import org.eclipse.tm.terminal.view.ui.activator.UIPlugin;
|
||||||
import org.eclipse.tm.terminal.view.ui.interfaces.ITerminalsView;
|
import org.eclipse.tm.terminal.view.ui.interfaces.ITerminalsView;
|
||||||
import org.eclipse.tm.terminal.view.ui.interfaces.IUIConstants;
|
|
||||||
import org.eclipse.tm.terminal.view.ui.interfaces.ImageConsts;
|
import org.eclipse.tm.terminal.view.ui.interfaces.ImageConsts;
|
||||||
import org.eclipse.tm.terminal.view.ui.manager.ConsoleManager;
|
|
||||||
import org.eclipse.tm.terminal.view.ui.nls.Messages;
|
import org.eclipse.tm.terminal.view.ui.nls.Messages;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
import org.eclipse.ui.commands.ICommandService;
|
||||||
|
import org.eclipse.ui.handlers.IHandlerService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a new terminal view with a new secondary view ID.
|
* Opens a new terminal view with a new secondary view ID.
|
||||||
|
@ -44,10 +51,27 @@ public class NewTerminalViewAction extends AbstractTerminalAction {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction#run()
|
* @see org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction#run()
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("cast")
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String secondaryId = ConsoleManager.getInstance().getNextTerminalSecondaryId(IUIConstants.ID);
|
ICommandService service = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
|
||||||
ConsoleManager.getInstance().showConsoleView(IUIConstants.ID, secondaryId);
|
Command command = service != null ? service.getCommand("org.eclipse.tm.terminal.view.ui.command.newview") : null; //$NON-NLS-1$
|
||||||
|
if (command != null && command.isDefined() && command.isEnabled()) {
|
||||||
|
try {
|
||||||
|
ParameterizedCommand pCmd = ParameterizedCommand.generateCommand(command, null);
|
||||||
|
Assert.isNotNull(pCmd);
|
||||||
|
IHandlerService handlerSvc = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class);
|
||||||
|
Assert.isNotNull(handlerSvc);
|
||||||
|
handlerSvc.executeCommandInContext(pCmd, null, handlerSvc.getCurrentState());
|
||||||
|
} catch (Exception e) {
|
||||||
|
// If the platform is in debug mode, we print the exception to the log view
|
||||||
|
if (Platform.inDebugMode()) {
|
||||||
|
IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
|
||||||
|
Messages.AbstractTriggerCommandHandler_error_executionFailed, e);
|
||||||
|
UIPlugin.getDefault().getLog().log(status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 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.tm.terminal.view.ui.internal.handler;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
import org.eclipse.tm.terminal.view.ui.interfaces.IUIConstants;
|
||||||
|
import org.eclipse.tm.terminal.view.ui.manager.ConsoleManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* New Terminal View handler implementation
|
||||||
|
*/
|
||||||
|
public class NewTerminalViewHandler extends AbstractTriggerCommandHandler {
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
|
String secondaryId = ConsoleManager.getInstance().getNextTerminalSecondaryId(IUIConstants.ID);
|
||||||
|
ConsoleManager.getInstance().showConsoleView(IUIConstants.ID, secondaryId);
|
||||||
|
|
||||||
|
triggerCommand("org.eclipse.tm.terminal.view.ui.command.launchToolbar", null); //$NON-NLS-1$
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue