1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Terminal: Prepare "New Terminal View" action

This commit is contained in:
Uwe Stieber 2015-06-15 09:15:37 +02:00
parent 121f0a2e00
commit 8eba787d83
9 changed files with 100 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 934 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

View file

@ -0,0 +1,47 @@
/*******************************************************************************
* 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.actions;
import org.eclipse.jface.action.IAction;
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.interfaces.ITerminalsView;
import org.eclipse.tm.terminal.view.ui.interfaces.ImageConsts;
import org.eclipse.tm.terminal.view.ui.nls.Messages;
/**
* Opens a new terminal view with a new secondary view ID.
*/
public class NewTerminalViewAction extends AbstractTerminalAction {
private ITerminalsView view = null;
/**
* Constructor.
*/
public NewTerminalViewAction(ITerminalsView view) {
super(null, NewTerminalViewAction.class.getName(), IAction.AS_PUSH_BUTTON);
this.view = view;
setupAction(Messages.NewTerminalViewAction_menu, Messages.NewTerminalViewAction_tooltip,
UIPlugin.getImageDescriptor(ImageConsts.ACTION_NewTerminalView_Hover),
UIPlugin.getImageDescriptor(ImageConsts.ACTION_NewTerminalView_Enabled),
UIPlugin.getImageDescriptor(ImageConsts.ACTION_NewTerminalView_Disabled), true);
setEnabled(true);
}
/* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction#run()
*/
@Override
public void run() {
}
}

View file

@ -239,6 +239,13 @@ public class UIPlugin extends AbstractUIPlugin {
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));
url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_CLCL + "new_terminal_view.gif"); //$NON-NLS-1$
registry.put(ImageConsts.ACTION_NewTerminalView_Hover, ImageDescriptor.createFromURL(url));
url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_ELCL + "new_terminal_view.gif"); //$NON-NLS-1$
registry.put(ImageConsts.ACTION_NewTerminalView_Enabled, ImageDescriptor.createFromURL(url));
url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_DLCL + "new_terminal_view.gif"); //$NON-NLS-1$
registry.put(ImageConsts.ACTION_NewTerminalView_Disabled, ImageDescriptor.createFromURL(url));
}
/**

View file

@ -79,6 +79,21 @@ public interface ImageConsts {
*/
public static final String ACTION_PinTerminal_Hover = "PinTerminalAction_hover"; //$NON-NLS-1$
/**
* The key to access the new terminal view action image (enabled).
*/
public static final String ACTION_NewTerminalView_Enabled = "NewTerminalViewAction_enabled"; //$NON-NLS-1$
/**
* The key to access the new terminal view action image (disabled).
*/
public static final String ACTION_NewTerminalView_Disabled = "NewTerminalViewAction_disabled"; //$NON-NLS-1$
/**
* The key to access the new terminal view action image (hover).
*/
public static final String ACTION_NewTerminalView_Hover = "NewTerminalViewAction_hover"; //$NON-NLS-1$
/**
* The key to access the toggle command field action image (enabled).
*/

View file

@ -73,6 +73,9 @@ public class Messages extends NLS {
public static String PinTerminalAction_menu;
public static String PinTerminalAction_toolTip;
public static String NewTerminalViewAction_menu;
public static String NewTerminalViewAction_tooltip;
public static String ToggleCommandFieldAction_menu;
public static String ToggleCommandFieldAction_toolTip;

View file

@ -31,6 +31,9 @@ TabTerminalListener_consoleConnecting={0} : {1}...
PinTerminalAction_menu=Pin
PinTerminalAction_toolTip=Pin the Terminal View
NewTerminalViewAction_menu=New Terminal View
NewTerminalViewAction_tooltip=Opens a new Terminal View
ToggleCommandFieldAction_menu=Toggle Command Input Field
ToggleCommandFieldAction_toolTip=Toggle Command Input Field

View file

@ -29,6 +29,7 @@ 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.tm.terminal.view.ui.actions.AbstractAction;
import org.eclipse.tm.terminal.view.ui.actions.NewTerminalViewAction;
import org.eclipse.tm.terminal.view.ui.actions.PinTerminalAction;
import org.eclipse.tm.terminal.view.ui.actions.TabScrollLockAction;
import org.eclipse.tm.terminal.view.ui.actions.ToggleCommandFieldAction;
@ -284,6 +285,17 @@ public class TabFolderToolbarHandler extends PlatformObject {
return getActiveTerminalViewControl();
}
});
// Create and add the new terminal view action
// add (new NewTerminalViewAction(getParentView()) {
// /* (non-Javadoc)
// * @see org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction#getTarget()
// */
// @Override
// protected ITerminalViewControl getTarget() {
// return getActiveTerminalViewControl();
// }
// });
}
/**
@ -301,7 +313,8 @@ public class TabFolderToolbarHandler extends PlatformObject {
manager.add(new Separator("anchor")); //$NON-NLS-1$
// we want that at the end
PinTerminalAction pinAction=null;
PinTerminalAction pinAction = null;
NewTerminalViewAction newTerminalAction = null;
// Loop all actions and add them to the menu manager
for (AbstractTerminalAction action : toolbarActions) {
@ -311,17 +324,25 @@ public class TabFolderToolbarHandler extends PlatformObject {
manager.insertAfter("anchor", new Separator()); //$NON-NLS-1$
}
// skip pin action for now
if(action instanceof PinTerminalAction){
if (action instanceof PinTerminalAction){
pinAction=(PinTerminalAction)action;
continue;
}
// skip new terminal view action for now
if (action instanceof NewTerminalViewAction){
newTerminalAction = (NewTerminalViewAction)action;
continue;
}
// Add the action itself
manager.insertAfter("anchor", action); //$NON-NLS-1$
}
// now add pin at the end
if(pinAction!=null){
if (pinAction != null){
manager.add(pinAction);
}
if (newTerminalAction != null){
manager.add(newTerminalAction);
}
}
/**
@ -337,7 +358,7 @@ public class TabFolderToolbarHandler extends PlatformObject {
// If the terminal control is not available, the updateAction
// method of certain actions enable the action (bugzilla #260372).
// Workaround by forcing the action to get disabled with setEnabled.
if (control == null && !(action instanceof PinTerminalAction)) {
if (control == null && !(action instanceof PinTerminalAction) && !(action instanceof NewTerminalViewAction)) {
action.setEnabled(false);
}
else {