mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
call Logger.encode only if logging is enabled
This commit is contained in:
parent
7a3ca9170a
commit
2fdbf8e3e2
2 changed files with 51 additions and 76 deletions
|
@ -311,8 +311,9 @@ public class TelnetConnection extends Thread implements TelnetCodes {
|
||||||
terminalControl.setState(TerminalState.CLOSED);
|
terminalControl.setState(TerminalState.CLOSED);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
Logger.log("Received " + nRawBytes + " bytes: '" + //$NON-NLS-1$ //$NON-NLS-2$
|
if(Logger.isLogEnabled())
|
||||||
Logger.encode(new String(rawBytes, 0, nRawBytes)) + "'"); //$NON-NLS-1$
|
Logger.log("Received " + nRawBytes + " bytes: '" + //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
Logger.encode(new String(rawBytes, 0, nRawBytes)) + "'"); //$NON-NLS-1$
|
||||||
|
|
||||||
// Process any TELNET protocol data that we receive. Don't
|
// Process any TELNET protocol data that we receive. Don't
|
||||||
// send any TELNET protocol data until we are sure the remote
|
// send any TELNET protocol data until we are sure the remote
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Preferences;
|
import org.eclipse.core.runtime.Preferences;
|
||||||
import org.eclipse.jface.action.ActionContributionItem;
|
import org.eclipse.jface.action.ActionContributionItem;
|
||||||
|
import org.eclipse.jface.action.IContributionItem;
|
||||||
import org.eclipse.jface.action.IMenuListener;
|
import org.eclipse.jface.action.IMenuListener;
|
||||||
import org.eclipse.jface.action.IMenuManager;
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
import org.eclipse.jface.action.IToolBarManager;
|
import org.eclipse.jface.action.IToolBarManager;
|
||||||
|
@ -613,28 +614,48 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected class TerminalMenuHandlerEdit implements MenuListener, IMenuListener {
|
protected class TerminalMenuHandlerEdit implements MenuListener, IMenuListener {
|
||||||
protected String fActionDefinitionIdCopy;
|
AcceleratorDisabler fAcceleratorDisablerCopy=new AcceleratorDisabler();
|
||||||
|
AcceleratorDisabler fAcceleratorDisablerPaste=new AcceleratorDisabler();
|
||||||
protected String fActionDefinitionIdPaste;
|
AcceleratorDisabler fAcceleratorDisablerSelectAll=new AcceleratorDisabler();
|
||||||
|
/**
|
||||||
protected String fActionDefinitionIdSelectAll;
|
* @author scharf
|
||||||
|
* 209656: [terminal] ClassCastException in TerminalView under Eclipse-3.4M3
|
||||||
protected int fAcceleratorCopy;
|
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=209656
|
||||||
|
*
|
||||||
protected int fAcceleratorPaste;
|
*
|
||||||
|
* TODO: eliminate this code.
|
||||||
protected int fAcceleratorSelectAll;
|
*/
|
||||||
|
class AcceleratorDisabler {
|
||||||
|
String fActionDefinitionId;
|
||||||
|
int fAccelerator;
|
||||||
|
ActionContributionItem fActionContributionItem;
|
||||||
|
public void menuAboutToShow(IContributionItem contribution) {
|
||||||
|
fActionContributionItem=null;
|
||||||
|
if(contribution instanceof ActionContributionItem) {
|
||||||
|
ActionContributionItem item = (ActionContributionItem) contribution;
|
||||||
|
if(item.getAction() instanceof RetargetAction) {
|
||||||
|
RetargetAction action = (RetargetAction) item.getAction();
|
||||||
|
fActionDefinitionId = action.getActionDefinitionId();
|
||||||
|
fAccelerator = action.getAccelerator();
|
||||||
|
action.setActionDefinitionId(null);
|
||||||
|
action.enableAccelerator(false);
|
||||||
|
item.update();
|
||||||
|
fActionContributionItem=item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void menuHidden() {
|
||||||
|
if(fActionContributionItem!=null) {
|
||||||
|
RetargetAction action = (RetargetAction) fActionContributionItem.getAction();
|
||||||
|
action.setActionDefinitionId(fActionDefinitionId);
|
||||||
|
action.setAccelerator(fAccelerator);
|
||||||
|
action.enableAccelerator(true);
|
||||||
|
fActionContributionItem.update();
|
||||||
|
fActionContributionItem=null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
protected TerminalMenuHandlerEdit() {
|
protected TerminalMenuHandlerEdit() {
|
||||||
super();
|
|
||||||
|
|
||||||
fActionDefinitionIdCopy = ""; //$NON-NLS-1$
|
|
||||||
fActionDefinitionIdPaste = ""; //$NON-NLS-1$
|
|
||||||
fActionDefinitionIdSelectAll = ""; //$NON-NLS-1$
|
|
||||||
|
|
||||||
fAcceleratorCopy = 0;
|
|
||||||
fAcceleratorPaste = 0;
|
|
||||||
fAcceleratorSelectAll = 0;
|
|
||||||
}
|
}
|
||||||
public void menuAboutToShow(IMenuManager menuMgr) {
|
public void menuAboutToShow(IMenuManager menuMgr) {
|
||||||
|
|
||||||
|
@ -643,68 +664,21 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
||||||
updateEditCut();
|
updateEditCut();
|
||||||
updateEditPaste();
|
updateEditPaste();
|
||||||
updateEditSelectAll();
|
updateEditSelectAll();
|
||||||
|
fAcceleratorDisablerCopy.menuAboutToShow(menuMgr.find(ActionFactory.COPY.getId()));
|
||||||
ActionContributionItem item = (ActionContributionItem) menuMgr.find(ActionFactory.COPY.getId());
|
fAcceleratorDisablerPaste.menuAboutToShow(menuMgr.find(ActionFactory.PASTE.getId()));
|
||||||
RetargetAction action = (RetargetAction) item.getAction();
|
fAcceleratorDisablerSelectAll.menuAboutToShow(menuMgr.find(ActionFactory.SELECT_ALL.getId()));
|
||||||
fActionDefinitionIdCopy = action.getActionDefinitionId();
|
|
||||||
fAcceleratorCopy = action.getAccelerator();
|
|
||||||
action.setActionDefinitionId(null);
|
|
||||||
action.enableAccelerator(false);
|
|
||||||
item.update();
|
|
||||||
|
|
||||||
item = (ActionContributionItem) menuMgr.find(ActionFactory.PASTE.getId());
|
|
||||||
action = (RetargetAction) item.getAction();
|
|
||||||
fActionDefinitionIdPaste = action.getActionDefinitionId();
|
|
||||||
fAcceleratorPaste = action.getAccelerator();
|
|
||||||
action.setActionDefinitionId(null);
|
|
||||||
action.enableAccelerator(false);
|
|
||||||
item.update();
|
|
||||||
|
|
||||||
item = (ActionContributionItem) menuMgr.find(ActionFactory.SELECT_ALL.getId());
|
|
||||||
action = (RetargetAction) item.getAction();
|
|
||||||
fActionDefinitionIdSelectAll = action.getActionDefinitionId();
|
|
||||||
fAcceleratorSelectAll = action.getAccelerator();
|
|
||||||
action.setActionDefinitionId(null);
|
|
||||||
action.enableAccelerator(false);
|
|
||||||
item.update();
|
|
||||||
}
|
}
|
||||||
public void menuShown(MenuEvent event) {
|
public void menuShown(MenuEvent event) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
public void menuHidden(MenuEvent event) {
|
public void menuHidden(MenuEvent event) {
|
||||||
MenuManager menuMgr;
|
|
||||||
ActionContributionItem item;
|
|
||||||
RetargetAction action;
|
|
||||||
|
|
||||||
fMenuAboutToShow = false;
|
fMenuAboutToShow = false;
|
||||||
updateEditCopy();
|
updateEditCopy();
|
||||||
updateEditCut();
|
updateEditCut();
|
||||||
|
|
||||||
menuMgr = getEditMenuManager();
|
fAcceleratorDisablerCopy.menuHidden();
|
||||||
|
fAcceleratorDisablerPaste.menuHidden();
|
||||||
item = (ActionContributionItem) menuMgr.find(ActionFactory.COPY
|
fAcceleratorDisablerSelectAll.menuHidden();
|
||||||
.getId());
|
|
||||||
action = (RetargetAction) item.getAction();
|
|
||||||
action.setActionDefinitionId(fActionDefinitionIdCopy);
|
|
||||||
action.setAccelerator(fAcceleratorCopy);
|
|
||||||
action.enableAccelerator(true);
|
|
||||||
item.update();
|
|
||||||
|
|
||||||
item = (ActionContributionItem) menuMgr.find(ActionFactory.PASTE
|
|
||||||
.getId());
|
|
||||||
action = (RetargetAction) item.getAction();
|
|
||||||
action.setActionDefinitionId(fActionDefinitionIdPaste);
|
|
||||||
action.setAccelerator(fAcceleratorPaste);
|
|
||||||
action.enableAccelerator(true);
|
|
||||||
item.update();
|
|
||||||
|
|
||||||
item = (ActionContributionItem) menuMgr
|
|
||||||
.find(ActionFactory.SELECT_ALL.getId());
|
|
||||||
action = (RetargetAction) item.getAction();
|
|
||||||
action.setActionDefinitionId(fActionDefinitionIdSelectAll);
|
|
||||||
action.setAccelerator(fAcceleratorSelectAll);
|
|
||||||
action.enableAccelerator(true);
|
|
||||||
item.update();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue