mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 22:22:11 +02:00
Replace "Pin&Clone" by the simpler "Open New Terminals View" action
The "Pin&Clone" concept is percieved complicated by the user. It is replaced by a more simpler concept where the user has an action to open a new "Terminals" view on demand. A new console is always opened in the last active "Terminals" view.
This commit is contained in:
parent
51f92ed895
commit
f5df46b150
11 changed files with 116 additions and 301 deletions
|
@ -13,7 +13,9 @@ 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.IUIConstants;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -21,7 +23,7 @@ import org.eclipse.tm.terminal.view.ui.nls.Messages;
|
|||
*/
|
||||
public class NewTerminalViewAction extends AbstractTerminalAction {
|
||||
|
||||
private ITerminalsView view = null;
|
||||
//private ITerminalsView view = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -29,7 +31,7 @@ public class NewTerminalViewAction extends AbstractTerminalAction {
|
|||
public NewTerminalViewAction(ITerminalsView view) {
|
||||
super(null, NewTerminalViewAction.class.getName(), IAction.AS_PUSH_BUTTON);
|
||||
|
||||
this.view = view;
|
||||
//this.view = view;
|
||||
setupAction(Messages.NewTerminalViewAction_menu, Messages.NewTerminalViewAction_tooltip,
|
||||
UIPlugin.getImageDescriptor(ImageConsts.ACTION_NewTerminalView_Hover),
|
||||
UIPlugin.getImageDescriptor(ImageConsts.ACTION_NewTerminalView_Enabled),
|
||||
|
@ -42,6 +44,8 @@ public class NewTerminalViewAction extends AbstractTerminalAction {
|
|||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
String secondaryId = ConsoleManager.getInstance().getNextTerminalSecondaryId(IUIConstants.ID);
|
||||
ConsoleManager.getInstance().showConsoleView(IUIConstants.ID, secondaryId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2011, 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;
|
||||
|
||||
/**
|
||||
* Pins the currently visible terminal view.
|
||||
*/
|
||||
public class PinTerminalAction extends AbstractTerminalAction {
|
||||
|
||||
private ITerminalsView view = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public PinTerminalAction(ITerminalsView view) {
|
||||
super(null, PinTerminalAction.class.getName(), IAction.AS_CHECK_BOX);
|
||||
|
||||
this.view = view;
|
||||
setupAction(Messages.PinTerminalAction_menu, Messages.PinTerminalAction_toolTip,
|
||||
UIPlugin.getImageDescriptor(ImageConsts.ACTION_PinTerminal_Hover),
|
||||
UIPlugin.getImageDescriptor(ImageConsts.ACTION_PinTerminal_Enabled),
|
||||
UIPlugin.getImageDescriptor(ImageConsts.ACTION_PinTerminal_Disabled), true);
|
||||
setChecked(view.isPinned());
|
||||
setEnabled(true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.action.IAction#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
view.setPinned(isChecked());
|
||||
}
|
||||
}
|
|
@ -223,13 +223,6 @@ public class UIPlugin extends AbstractUIPlugin {
|
|||
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();
|
||||
|
|
|
@ -34,19 +34,4 @@ public interface ITerminalsView extends IViewPart {
|
|||
* @return The context help id or <code>null</code> if none is associated.
|
||||
*/
|
||||
public String getContextHelpId();
|
||||
|
||||
/**
|
||||
* Set the state of the view to be pinned, which means a new terminal tab will be created
|
||||
* in a new view instance.
|
||||
*
|
||||
* @param pin <code>True</code> to set the view state to pinned, <code>false</code> otherwise.
|
||||
*/
|
||||
public void setPinned(boolean pin);
|
||||
|
||||
/**
|
||||
* Return the pin state of the terminal view
|
||||
*
|
||||
* @return <code>True</code> if the view instance is pinned, <code>false</code> if not.
|
||||
*/
|
||||
public boolean isPinned();
|
||||
}
|
||||
|
|
|
@ -64,21 +64,6 @@ public interface ImageConsts {
|
|||
*/
|
||||
public static final String ACTION_ScrollLock_Hover = "ScrollLockAction_hover"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The key to access the pin terminal action image (enabled).
|
||||
*/
|
||||
public static final String ACTION_PinTerminal_Enabled = "PinTerminalAction_enabled"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The key to access the pin terminal action image (disabled).
|
||||
*/
|
||||
public static final String ACTION_PinTerminal_Disabled = "PinTerminalAction_disabled"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The key to access the pin terminal action image (hover).
|
||||
*/
|
||||
public static final String ACTION_PinTerminal_Hover = "PinTerminalAction_hover"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The key to access the new terminal view action image (enabled).
|
||||
*/
|
||||
|
|
|
@ -32,12 +32,16 @@ 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.tabs.TabFolderManager;
|
||||
import org.eclipse.tm.terminal.view.ui.view.TerminalsView;
|
||||
import org.eclipse.ui.IPartListener2;
|
||||
import org.eclipse.ui.IPartService;
|
||||
import org.eclipse.ui.IPerspectiveDescriptor;
|
||||
import org.eclipse.ui.IPerspectiveListener;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IViewReference;
|
||||
import org.eclipse.ui.IViewSite;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.IWorkbenchPartReference;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.PerspectiveAdapter;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
@ -95,6 +99,55 @@ public class ConsoleManager {
|
|||
}
|
||||
}
|
||||
|
||||
// Reference to the part listener instance
|
||||
private final IPartListener2 partListener;
|
||||
|
||||
// The ids of the last activated terminals view
|
||||
/* default */ String lastActiveViewId = null;
|
||||
/* default */ String lastActiveSecondaryViewId = null;
|
||||
|
||||
// Internal part listener implementation
|
||||
class ConsoleManagerPartListener implements IPartListener2 {
|
||||
|
||||
@Override
|
||||
public void partActivated(IWorkbenchPartReference partRef) {
|
||||
IWorkbenchPart part = partRef.getPart(false);
|
||||
if (part instanceof ITerminalsView) {
|
||||
lastActiveViewId = ((ITerminalsView)part).getViewSite().getId();
|
||||
lastActiveSecondaryViewId = ((ITerminalsView)part).getViewSite().getSecondaryId();
|
||||
//System.out.println("Terminals view activated: id = " + lastActiveViewId + ", secondary id = " + lastActiveSecondaryViewId); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partBroughtToTop(IWorkbenchPartReference partRef) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partClosed(IWorkbenchPartReference partRef) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partDeactivated(IWorkbenchPartReference partRef) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partOpened(IWorkbenchPartReference partRef) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partHidden(IWorkbenchPartReference partRef) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partVisible(IWorkbenchPartReference partRef) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partInputChanged(IWorkbenchPartReference partRef) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Thread save singleton instance creation.
|
||||
*/
|
||||
|
@ -115,10 +168,14 @@ public class ConsoleManager {
|
|||
ConsoleManager() {
|
||||
super();
|
||||
|
||||
// Attach the perspective listener
|
||||
perspectiveListener = new ConsoleManagerPerspectiveListener();
|
||||
partListener = new ConsoleManagerPartListener();
|
||||
|
||||
if (PlatformUI.isWorkbenchRunning() && PlatformUI.getWorkbench() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
|
||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(perspectiveListener);
|
||||
|
||||
IPartService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService();
|
||||
service.addPartListener(partListener);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,7 +211,7 @@ public class ConsoleManager {
|
|||
IWorkbenchPage page = getActiveWorkbenchPage();
|
||||
if (page != null) {
|
||||
// Look for the view
|
||||
IViewPart part = getTerminalsViewWithSecondaryId(id != null ? id : IUIConstants.ID, secondaryId);
|
||||
IViewPart part = getTerminalsViewWithSecondaryId(id != null ? id : IUIConstants.ID, secondaryId, true);
|
||||
// Check the interface
|
||||
if (part instanceof ITerminalsView) {
|
||||
view = (ITerminalsView)part;
|
||||
|
@ -169,66 +226,11 @@ public class ConsoleManager {
|
|||
*
|
||||
* @param id The terminals console view id. Must not be <code>null</code>.
|
||||
* @param secondaryId The terminals console view secondary id or <code>null</code>.
|
||||
* @param restore <code>True</code> if to try to restore the view, <code>false</code> otherwise.
|
||||
*
|
||||
* @return The terminals console view instance or <code>null</code> if not found.
|
||||
*/
|
||||
private IViewPart getTerminalsViewWithSecondaryId(String id, String secondaryId) {
|
||||
Assert.isNotNull(id);
|
||||
|
||||
IWorkbenchPage page = getActiveWorkbenchPage();
|
||||
|
||||
IViewReference[] refs = page.getViewReferences();
|
||||
for (int i = 0; i < refs.length; i++) {
|
||||
IViewReference ref = refs[i];
|
||||
if (ref.getId().equals(id)) {
|
||||
IViewPart part = ref.getView(true);
|
||||
if (part instanceof ITerminalsView) {
|
||||
String secId = ((IViewSite) part.getSite()).getSecondaryId();
|
||||
if (secId != null && secId.equals(secondaryId) || secId == null && secondaryId == null) {
|
||||
return part;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search and return a terminal view that is NOT pinned
|
||||
*
|
||||
* @param id The terminals console view id. Must not be <code>null</code>.
|
||||
* @return The terminals console view instance or <code>null</code> if not found.
|
||||
*/
|
||||
private IViewPart getFirstNotPinnedTerminalsView(String id) {
|
||||
Assert.isNotNull(id);
|
||||
|
||||
IWorkbenchPage page = getActiveWorkbenchPage();
|
||||
|
||||
IViewReference[] refs = page.getViewReferences();
|
||||
for (int i = 0; i < refs.length; i++) {
|
||||
IViewReference ref = refs[i];
|
||||
if (ref.getId().equals(id)) {
|
||||
IViewPart part = ref.getView(true);
|
||||
if (part instanceof ITerminalsView) {
|
||||
if (!((ITerminalsView) part).isPinned()) {
|
||||
return part;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search and return the first available terminal view.
|
||||
*
|
||||
* @param id The terminals console view id. Must not be <code>null</code>.
|
||||
* @param secondaryId The terminals console view secondary id or <code>null</code>.
|
||||
* @param useActive - return only an active terminal view.
|
||||
*
|
||||
* @return The terminals console view instance or <code>null</code> if not found.
|
||||
*/
|
||||
private IViewPart getFirstTerminalsView(String id, String secondaryId, boolean useActive) {
|
||||
private IViewPart getTerminalsViewWithSecondaryId(String id, String secondaryId, boolean restore) {
|
||||
Assert.isNotNull(id);
|
||||
|
||||
IWorkbenchPage page = getActiveWorkbenchPage();
|
||||
|
@ -238,30 +240,51 @@ public class ConsoleManager {
|
|||
IViewReference ref = refs[i];
|
||||
if (ref.getId().equals(id)) {
|
||||
if (ANY_SECONDARY_ID.equals(secondaryId)
|
||||
|| secondaryId == null && ref.getSecondaryId() == null
|
||||
|| secondaryId != null && secondaryId.equals(ref.getSecondaryId())) {
|
||||
IViewPart part = ref.getView(true);
|
||||
if (useActive) {
|
||||
if (page.isPartVisible(part)) {
|
||||
return part;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return part;
|
||||
}
|
||||
|| secondaryId == null && ref.getSecondaryId() == null
|
||||
|| secondaryId != null && secondaryId.equals(ref.getSecondaryId())) {
|
||||
return ref.getView(restore);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search and return the active terminals view.
|
||||
*
|
||||
* @param id The terminals console view id. Must not be <code>null</code>.
|
||||
* @param secondaryId The terminals console view secondary id or <code>null</code>.
|
||||
* @return The terminals console view instance or <code>null</code> if not found.
|
||||
*/
|
||||
private IViewPart getActiveTerminalsView(String id, String secondaryId) {
|
||||
Assert.isNotNull(id);
|
||||
|
||||
IViewPart part = null;
|
||||
|
||||
if (id.equals(lastActiveViewId)) {
|
||||
if (secondaryId == null || ANY_SECONDARY_ID.equals(secondaryId) || secondaryId.equals(lastActiveSecondaryViewId)) {
|
||||
part = getTerminalsViewWithSecondaryId(lastActiveViewId, lastActiveSecondaryViewId, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (part == null) {
|
||||
part = getTerminalsViewWithSecondaryId(id, secondaryId, true);
|
||||
if (part != null) {
|
||||
lastActiveViewId = part.getViewSite().getId();
|
||||
lastActiveSecondaryViewId = part.getViewSite().getSecondaryId();
|
||||
}
|
||||
}
|
||||
|
||||
return part;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new secondary id to use, based on the number of open terminal views.
|
||||
*
|
||||
* @param id The terminals console view id. Must not be <code>null</code>.
|
||||
* @return The next secondary id, or <code>null</code> if it is the first one
|
||||
*/
|
||||
private String getNextTerminalSecondaryId(String id) {
|
||||
public String getNextTerminalSecondaryId(String id) {
|
||||
Assert.isNotNull(id);
|
||||
|
||||
IWorkbenchPage page = getActiveWorkbenchPage();
|
||||
|
@ -318,7 +341,8 @@ public class ConsoleManager {
|
|||
if (page != null) {
|
||||
try {
|
||||
// show the view
|
||||
IViewPart part = page.showView(id != null ? id : IUIConstants.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
|
||||
IViewPart part = getActiveTerminalsView(id != null ? id : IUIConstants.ID, secondaryId);
|
||||
if (part == null) part = page.showView(id != null ? id : IUIConstants.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
|
||||
// and force the view to the foreground
|
||||
page.bringToTop(part);
|
||||
return part;
|
||||
|
@ -342,55 +366,18 @@ public class ConsoleManager {
|
|||
// Get the active workbench page
|
||||
IWorkbenchPage page = getActiveWorkbenchPage();
|
||||
if (page != null) {
|
||||
// Look for any terminal view
|
||||
IViewPart anyTerminal = getFirstTerminalsView(id != null ? id : IUIConstants.ID, secondaryId, false);
|
||||
// there is at least one terminal available
|
||||
if (anyTerminal != null) {
|
||||
// is there an active terminal view
|
||||
IViewPart activePart = getFirstTerminalsView(id != null ? id : IUIConstants.ID, secondaryId, true);
|
||||
// no terminal view active
|
||||
if (activePart == null) {
|
||||
// use the first not pinned
|
||||
IViewPart notPinnedPart = getFirstNotPinnedTerminalsView(id != null ? id : IUIConstants.ID);
|
||||
if (notPinnedPart != null) {
|
||||
if (activate) {
|
||||
page.activate(notPinnedPart);
|
||||
}
|
||||
else {
|
||||
page.bringToTop(notPinnedPart);
|
||||
}
|
||||
return notPinnedPart;
|
||||
}
|
||||
// else we need to create a new one
|
||||
IViewPart newPart = showConsoleView(id != null ? id : IUIConstants.ID, getSecondaryId(secondaryId, id));
|
||||
return newPart;
|
||||
}
|
||||
// we found a active terminal page
|
||||
// if it is pinned search for a non pinned (not active)
|
||||
if (((ITerminalsView) activePart).isPinned() && ANY_SECONDARY_ID.equals(secondaryId)) {
|
||||
// we found one so use it
|
||||
IViewPart notPinnedPart = getFirstNotPinnedTerminalsView(id != null ? id : IUIConstants.ID);
|
||||
if (notPinnedPart != null) {
|
||||
if (activate) {
|
||||
page.activate(notPinnedPart);
|
||||
}
|
||||
else {
|
||||
page.bringToTop(notPinnedPart);
|
||||
}
|
||||
return notPinnedPart;
|
||||
}
|
||||
// else we need to create a new one
|
||||
IViewPart newPart = showConsoleView(id != null ? id : IUIConstants.ID, getSecondaryId(secondaryId, id));
|
||||
return newPart;
|
||||
}
|
||||
// else return the active one
|
||||
return activePart;
|
||||
}
|
||||
// create first new terminal
|
||||
if (activate) {
|
||||
// get (last) active terminal view
|
||||
IViewPart activePart = getActiveTerminalsView(id != null ? id : IUIConstants.ID, secondaryId);
|
||||
if (activePart == null) {
|
||||
// Create a new one
|
||||
IViewPart newPart = showConsoleView(id != null ? id : IUIConstants.ID, getSecondaryId(secondaryId, id));
|
||||
return newPart;
|
||||
}
|
||||
|
||||
if (activate) page.activate(activePart);
|
||||
else page.bringToTop(activePart);
|
||||
|
||||
return activePart;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -70,9 +70,6 @@ public class Messages extends NLS {
|
|||
public static String TabTerminalListener_consoleClosed;
|
||||
public static String TabTerminalListener_consoleConnecting;
|
||||
|
||||
public static String PinTerminalAction_menu;
|
||||
public static String PinTerminalAction_toolTip;
|
||||
|
||||
public static String NewTerminalViewAction_menu;
|
||||
public static String NewTerminalViewAction_tooltip;
|
||||
|
||||
|
|
|
@ -28,9 +28,6 @@ AbstractConfigurationPanel_encoding_custom_error=Unsupported encoding. Please en
|
|||
TabTerminalListener_consoleClosed=<{1}> {0}
|
||||
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
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ 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;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.ITerminalsView;
|
||||
|
@ -275,8 +274,8 @@ public class TabFolderToolbarHandler extends PlatformObject {
|
|||
}
|
||||
});
|
||||
|
||||
// Create and add the pin view action
|
||||
add (new PinTerminalAction(getParentView()) {
|
||||
// Create and add the new terminal view action
|
||||
add (new NewTerminalViewAction(getParentView()) {
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction#getTarget()
|
||||
*/
|
||||
|
@ -285,17 +284,6 @@ 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();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -313,7 +301,6 @@ public class TabFolderToolbarHandler extends PlatformObject {
|
|||
manager.add(new Separator("anchor")); //$NON-NLS-1$
|
||||
|
||||
// we want that at the end
|
||||
PinTerminalAction pinAction = null;
|
||||
NewTerminalViewAction newTerminalAction = null;
|
||||
|
||||
// Loop all actions and add them to the menu manager
|
||||
|
@ -323,11 +310,6 @@ public class TabFolderToolbarHandler extends PlatformObject {
|
|||
|| (action instanceof AbstractAction && ((AbstractAction)action).isSeparator())) {
|
||||
manager.insertAfter("anchor", new Separator()); //$NON-NLS-1$
|
||||
}
|
||||
// skip pin action for now
|
||||
if (action instanceof PinTerminalAction){
|
||||
pinAction=(PinTerminalAction)action;
|
||||
continue;
|
||||
}
|
||||
// skip new terminal view action for now
|
||||
if (action instanceof NewTerminalViewAction){
|
||||
newTerminalAction = (NewTerminalViewAction)action;
|
||||
|
@ -336,10 +318,7 @@ public class TabFolderToolbarHandler extends PlatformObject {
|
|||
// Add the action itself
|
||||
manager.insertAfter("anchor", action); //$NON-NLS-1$
|
||||
}
|
||||
// now add pin at the end
|
||||
if (pinAction != null){
|
||||
manager.add(pinAction);
|
||||
}
|
||||
// now add to the end
|
||||
if (newTerminalAction != null){
|
||||
manager.add(newTerminalAction);
|
||||
}
|
||||
|
@ -358,7 +337,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) && !(action instanceof NewTerminalViewAction)) {
|
||||
if (control == null && !(action instanceof NewTerminalViewAction)) {
|
||||
action.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -86,8 +86,6 @@ public class TerminalsView extends ViewPart implements ITerminalsView, IShowInTa
|
|||
private TabFolderToolbarHandler tabFolderToolbarHandler;
|
||||
// Reference to the empty page control (to be show if no console is open)
|
||||
private Control emptyPageControl;
|
||||
// Whether this terminal is pinned.
|
||||
private boolean pinned = false;
|
||||
// The view's memento handler
|
||||
private final TerminalsViewMementoHandler mementoHandler = new TerminalsViewMementoHandler();
|
||||
|
||||
|
@ -629,22 +627,6 @@ public class TerminalsView extends ViewPart implements ITerminalsView, IShowInTa
|
|||
return super.getAdapter(adapter);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.ITerminalsView#setPinned(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPinned(boolean pin) {
|
||||
this.pinned = pin;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.ITerminalsView#isPinned()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPinned() {
|
||||
return pinned;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.part.ViewPart#saveState(org.eclipse.ui.IMemento)
|
||||
*/
|
||||
|
|
|
@ -13,19 +13,14 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.swt.custom.CTabItem;
|
||||
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
|
||||
import org.eclipse.tm.terminal.view.core.interfaces.ITerminalService;
|
||||
import org.eclipse.tm.terminal.view.core.interfaces.constants.ITerminalsConnectorConstants;
|
||||
import org.eclipse.tm.terminal.view.ui.actions.PinTerminalAction;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.IMementoHandler;
|
||||
import org.eclipse.tm.terminal.view.ui.launcher.LauncherDelegateManager;
|
||||
import org.eclipse.tm.terminal.view.ui.tabs.TabFolderToolbarHandler;
|
||||
import org.eclipse.ui.IMemento;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
|
@ -68,9 +63,6 @@ public class TerminalsViewMementoHandler {
|
|||
memento.putString("id", view.getViewSite().getId()); //$NON-NLS-1$
|
||||
memento.putString("secondaryId", view.getViewSite().getSecondaryId()); //$NON-NLS-1$
|
||||
|
||||
// Save the pinned state
|
||||
memento.putBoolean("pinned", view.isPinned()); //$NON-NLS-1$
|
||||
|
||||
// Loop the saveable items and store the connection data of each
|
||||
// item to the memento
|
||||
for (CTabItem item : saveables) {
|
||||
|
@ -133,31 +125,6 @@ public class TerminalsViewMementoHandler {
|
|||
String secondaryId = memento.getString("secondaryId"); //$NON-NLS-1$
|
||||
if ("null".equals(secondaryId)) secondaryId = null; //$NON-NLS-1$
|
||||
|
||||
final IMemento finMemento = memento;
|
||||
// Restore the pinned state of the after all connections completed
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (finMemento.getBoolean("pinned") != null) { //$NON-NLS-1$
|
||||
asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
view.setPinned(finMemento.getBoolean("pinned").booleanValue()); //$NON-NLS-1$
|
||||
|
||||
TabFolderToolbarHandler toolbarHandler = (TabFolderToolbarHandler)view.getAdapter(TabFolderToolbarHandler.class);
|
||||
if (toolbarHandler != null) {
|
||||
PinTerminalAction action = (PinTerminalAction)toolbarHandler.getAdapter(PinTerminalAction.class);
|
||||
if (action != null) action.setChecked(view.isPinned());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
final AtomicBoolean allProcessed = new AtomicBoolean(false);
|
||||
final List<ITerminalService.Done> callbacks = new ArrayList<ITerminalService.Done>();
|
||||
|
||||
// Get all the "connection" memento's.
|
||||
IMemento[] connections = memento.getChildren("connection"); //$NON-NLS-1$
|
||||
for (IMemento connection : connections) {
|
||||
|
@ -191,22 +158,9 @@ public class TerminalsViewMementoHandler {
|
|||
|
||||
// Restore the terminal connection
|
||||
if (delegate != null && !properties.isEmpty()) {
|
||||
ITerminalService.Done done = new ITerminalService.Done() {
|
||||
@Override
|
||||
public void done(IStatus status) {
|
||||
callbacks.remove(this);
|
||||
if (allProcessed.get() && callbacks.isEmpty()) {
|
||||
asyncExec(runnable);
|
||||
}
|
||||
}
|
||||
};
|
||||
callbacks.add(done);
|
||||
delegate.execute(properties, done);
|
||||
delegate.execute(properties, null);
|
||||
}
|
||||
}
|
||||
|
||||
allProcessed.set(true);
|
||||
if (callbacks.isEmpty()) asyncExec(runnable);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue