1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42: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:
Uwe Stieber 2015-08-10 15:07:35 +02:00
parent 51f92ed895
commit f5df46b150
11 changed files with 116 additions and 301 deletions

View file

@ -13,7 +13,9 @@ 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;
/** /**
@ -21,7 +23,7 @@ import org.eclipse.tm.terminal.view.ui.nls.Messages;
*/ */
public class NewTerminalViewAction extends AbstractTerminalAction { public class NewTerminalViewAction extends AbstractTerminalAction {
private ITerminalsView view = null; //private ITerminalsView view = null;
/** /**
* Constructor. * Constructor.
@ -29,7 +31,7 @@ public class NewTerminalViewAction extends AbstractTerminalAction {
public NewTerminalViewAction(ITerminalsView view) { public NewTerminalViewAction(ITerminalsView view) {
super(null, NewTerminalViewAction.class.getName(), IAction.AS_PUSH_BUTTON); super(null, NewTerminalViewAction.class.getName(), IAction.AS_PUSH_BUTTON);
this.view = view; //this.view = view;
setupAction(Messages.NewTerminalViewAction_menu, Messages.NewTerminalViewAction_tooltip, setupAction(Messages.NewTerminalViewAction_menu, Messages.NewTerminalViewAction_tooltip,
UIPlugin.getImageDescriptor(ImageConsts.ACTION_NewTerminalView_Hover), UIPlugin.getImageDescriptor(ImageConsts.ACTION_NewTerminalView_Hover),
UIPlugin.getImageDescriptor(ImageConsts.ACTION_NewTerminalView_Enabled), UIPlugin.getImageDescriptor(ImageConsts.ACTION_NewTerminalView_Enabled),
@ -42,6 +44,8 @@ public class NewTerminalViewAction extends AbstractTerminalAction {
*/ */
@Override @Override
public void run() { public void run() {
String secondaryId = ConsoleManager.getInstance().getNextTerminalSecondaryId(IUIConstants.ID);
ConsoleManager.getInstance().showConsoleView(IUIConstants.ID, secondaryId);
} }
} }

View file

@ -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());
}
}

View file

@ -223,13 +223,6 @@ public class UIPlugin extends AbstractUIPlugin {
registry.put(ImageConsts.ACTION_ScrollLock_Enabled, ImageDescriptor.createFromURL(url)); 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$ 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)); 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(); bundle = getBundle();

View file

@ -34,19 +34,4 @@ public interface ITerminalsView extends IViewPart {
* @return The context help id or <code>null</code> if none is associated. * @return The context help id or <code>null</code> if none is associated.
*/ */
public String getContextHelpId(); 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();
} }

View file

@ -64,21 +64,6 @@ public interface ImageConsts {
*/ */
public static final String ACTION_ScrollLock_Hover = "ScrollLockAction_hover"; //$NON-NLS-1$ 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). * The key to access the new terminal view action image (enabled).
*/ */

View file

@ -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.interfaces.IUIConstants;
import org.eclipse.tm.terminal.view.ui.tabs.TabFolderManager; import org.eclipse.tm.terminal.view.ui.tabs.TabFolderManager;
import org.eclipse.tm.terminal.view.ui.view.TerminalsView; 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.IPerspectiveDescriptor;
import org.eclipse.ui.IPerspectiveListener; import org.eclipse.ui.IPerspectiveListener;
import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference; import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IViewSite; import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.PartInitException; import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PerspectiveAdapter; import org.eclipse.ui.PerspectiveAdapter;
import org.eclipse.ui.PlatformUI; 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. * Thread save singleton instance creation.
*/ */
@ -115,10 +168,14 @@ public class ConsoleManager {
ConsoleManager() { ConsoleManager() {
super(); super();
// Attach the perspective listener
perspectiveListener = new ConsoleManagerPerspectiveListener(); perspectiveListener = new ConsoleManagerPerspectiveListener();
partListener = new ConsoleManagerPartListener();
if (PlatformUI.isWorkbenchRunning() && PlatformUI.getWorkbench() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) { if (PlatformUI.isWorkbenchRunning() && PlatformUI.getWorkbench() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(perspectiveListener); PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(perspectiveListener);
IPartService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService();
service.addPartListener(partListener);
} }
} }
@ -154,7 +211,7 @@ public class ConsoleManager {
IWorkbenchPage page = getActiveWorkbenchPage(); IWorkbenchPage page = getActiveWorkbenchPage();
if (page != null) { if (page != null) {
// Look for the view // 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 // Check the interface
if (part instanceof ITerminalsView) { if (part instanceof ITerminalsView) {
view = (ITerminalsView)part; view = (ITerminalsView)part;
@ -169,66 +226,11 @@ public class ConsoleManager {
* *
* @param id The terminals console view id. Must not be <code>null</code>. * @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 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. * @return The terminals console view instance or <code>null</code> if not found.
*/ */
private IViewPart getTerminalsViewWithSecondaryId(String id, String secondaryId) { private IViewPart getTerminalsViewWithSecondaryId(String id, String secondaryId, boolean restore) {
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) {
Assert.isNotNull(id); Assert.isNotNull(id);
IWorkbenchPage page = getActiveWorkbenchPage(); IWorkbenchPage page = getActiveWorkbenchPage();
@ -238,30 +240,51 @@ public class ConsoleManager {
IViewReference ref = refs[i]; IViewReference ref = refs[i];
if (ref.getId().equals(id)) { if (ref.getId().equals(id)) {
if (ANY_SECONDARY_ID.equals(secondaryId) if (ANY_SECONDARY_ID.equals(secondaryId)
|| secondaryId == null && ref.getSecondaryId() == null || secondaryId == null && ref.getSecondaryId() == null
|| secondaryId != null && secondaryId.equals(ref.getSecondaryId())) { || secondaryId != null && secondaryId.equals(ref.getSecondaryId())) {
IViewPart part = ref.getView(true); return ref.getView(restore);
if (useActive) {
if (page.isPartVisible(part)) {
return part;
}
}
else {
return part;
}
} }
} }
} }
return null; 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. * 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>. * @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 * @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); Assert.isNotNull(id);
IWorkbenchPage page = getActiveWorkbenchPage(); IWorkbenchPage page = getActiveWorkbenchPage();
@ -318,7 +341,8 @@ public class ConsoleManager {
if (page != null) { if (page != null) {
try { try {
// show the view // 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 // and force the view to the foreground
page.bringToTop(part); page.bringToTop(part);
return part; return part;
@ -342,55 +366,18 @@ public class ConsoleManager {
// Get the active workbench page // Get the active workbench page
IWorkbenchPage page = getActiveWorkbenchPage(); IWorkbenchPage page = getActiveWorkbenchPage();
if (page != null) { if (page != null) {
// Look for any terminal view // get (last) active terminal view
IViewPart anyTerminal = getFirstTerminalsView(id != null ? id : IUIConstants.ID, secondaryId, false); IViewPart activePart = getActiveTerminalsView(id != null ? id : IUIConstants.ID, secondaryId);
// there is at least one terminal available if (activePart == null) {
if (anyTerminal != null) { // Create a new one
// 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) {
IViewPart newPart = showConsoleView(id != null ? id : IUIConstants.ID, getSecondaryId(secondaryId, id)); IViewPart newPart = showConsoleView(id != null ? id : IUIConstants.ID, getSecondaryId(secondaryId, id));
return newPart; return newPart;
} }
if (activate) page.activate(activePart);
else page.bringToTop(activePart);
return activePart;
} }
return null; return null;
} }

View file

@ -70,9 +70,6 @@ public class Messages extends NLS {
public static String TabTerminalListener_consoleClosed; public static String TabTerminalListener_consoleClosed;
public static String TabTerminalListener_consoleConnecting; public static String TabTerminalListener_consoleConnecting;
public static String PinTerminalAction_menu;
public static String PinTerminalAction_toolTip;
public static String NewTerminalViewAction_menu; public static String NewTerminalViewAction_menu;
public static String NewTerminalViewAction_tooltip; public static String NewTerminalViewAction_tooltip;

View file

@ -28,9 +28,6 @@ AbstractConfigurationPanel_encoding_custom_error=Unsupported encoding. Please en
TabTerminalListener_consoleClosed=<{1}> {0} TabTerminalListener_consoleClosed=<{1}> {0}
TabTerminalListener_consoleConnecting={0} : {1}... TabTerminalListener_consoleConnecting={0} : {1}...
PinTerminalAction_menu=Pin
PinTerminalAction_toolTip=Pin the Terminal View
NewTerminalViewAction_menu=New Terminal View NewTerminalViewAction_menu=New Terminal View
NewTerminalViewAction_tooltip=Opens a new Terminal View NewTerminalViewAction_tooltip=Opens a new Terminal View

View file

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

View file

@ -86,8 +86,6 @@ public class TerminalsView extends ViewPart implements ITerminalsView, IShowInTa
private TabFolderToolbarHandler tabFolderToolbarHandler; private TabFolderToolbarHandler tabFolderToolbarHandler;
// Reference to the empty page control (to be show if no console is open) // Reference to the empty page control (to be show if no console is open)
private Control emptyPageControl; private Control emptyPageControl;
// Whether this terminal is pinned.
private boolean pinned = false;
// The view's memento handler // The view's memento handler
private final TerminalsViewMementoHandler mementoHandler = new TerminalsViewMementoHandler(); private final TerminalsViewMementoHandler mementoHandler = new TerminalsViewMementoHandler();
@ -629,22 +627,6 @@ public class TerminalsView extends ViewPart implements ITerminalsView, IShowInTa
return super.getAdapter(adapter); 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) /* (non-Javadoc)
* @see org.eclipse.ui.part.ViewPart#saveState(org.eclipse.ui.IMemento) * @see org.eclipse.ui.part.ViewPart#saveState(org.eclipse.ui.IMemento)
*/ */

View file

@ -13,19 +13,14 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.custom.CTabItem;
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; 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.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.ILauncherDelegate;
import org.eclipse.tm.terminal.view.ui.interfaces.IMementoHandler; 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.launcher.LauncherDelegateManager;
import org.eclipse.tm.terminal.view.ui.tabs.TabFolderToolbarHandler;
import org.eclipse.ui.IMemento; import org.eclipse.ui.IMemento;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
@ -68,9 +63,6 @@ public class TerminalsViewMementoHandler {
memento.putString("id", view.getViewSite().getId()); //$NON-NLS-1$ memento.putString("id", view.getViewSite().getId()); //$NON-NLS-1$
memento.putString("secondaryId", view.getViewSite().getSecondaryId()); //$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 // Loop the saveable items and store the connection data of each
// item to the memento // item to the memento
for (CTabItem item : saveables) { for (CTabItem item : saveables) {
@ -133,31 +125,6 @@ public class TerminalsViewMementoHandler {
String secondaryId = memento.getString("secondaryId"); //$NON-NLS-1$ String secondaryId = memento.getString("secondaryId"); //$NON-NLS-1$
if ("null".equals(secondaryId)) secondaryId = null; //$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. // Get all the "connection" memento's.
IMemento[] connections = memento.getChildren("connection"); //$NON-NLS-1$ IMemento[] connections = memento.getChildren("connection"); //$NON-NLS-1$
for (IMemento connection : connections) { for (IMemento connection : connections) {
@ -191,22 +158,9 @@ public class TerminalsViewMementoHandler {
// Restore the terminal connection // Restore the terminal connection
if (delegate != null && !properties.isEmpty()) { if (delegate != null && !properties.isEmpty()) {
ITerminalService.Done done = new ITerminalService.Done() { delegate.execute(properties, null);
@Override
public void done(IStatus status) {
callbacks.remove(this);
if (allProcessed.get() && callbacks.isEmpty()) {
asyncExec(runnable);
}
}
};
callbacks.add(done);
delegate.execute(properties, done);
} }
} }
allProcessed.set(true);
if (callbacks.isEmpty()) asyncExec(runnable);
} }
} }