mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-13 03:55:22 +02:00
Apply from 3.0.3: [247700] Terminal uses ugly fonts in JEE package
This commit is contained in:
parent
4999018e4f
commit
7dd15dcf0e
2 changed files with 79 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2002, 2009 IBM Corporation 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
|
||||
|
@ -19,6 +19,7 @@
|
|||
* Martin Oberhuber (Wind River) - [227571] RSE Terminal should honor Encoding set on the IHost
|
||||
* Michael Scharf (Wind River) - [236203] [rseterminal] Potentially UI blocking code in TerminalViewTab.createTabItem
|
||||
* Anna Dushistova (MontaVista) - [244437] [rseterminal] Possible race condition when multiple Terminals are launched after each other
|
||||
* Martin Oberhuber (Wind River) - [247700] Terminal uses ugly fonts in JEE package
|
||||
********************************************************************************/
|
||||
package org.eclipse.rse.internal.terminals.ui.views;
|
||||
|
||||
|
@ -29,6 +30,9 @@ import org.eclipse.jface.action.IMenuListener;
|
|||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.action.MenuManager;
|
||||
import org.eclipse.jface.action.Separator;
|
||||
import org.eclipse.jface.resource.FontRegistry;
|
||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
import org.eclipse.rse.core.RSECorePlugin;
|
||||
import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
|
||||
import org.eclipse.rse.core.events.SystemResourceChangeEvent;
|
||||
|
@ -45,6 +49,7 @@ import org.eclipse.swt.events.DisposeEvent;
|
|||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.events.MenuEvent;
|
||||
import org.eclipse.swt.events.MenuListener;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
@ -61,6 +66,8 @@ import org.eclipse.tm.internal.terminal.control.actions.TerminalActionPaste;
|
|||
import org.eclipse.tm.internal.terminal.control.actions.TerminalActionSelectAll;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.themes.IThemeManager;
|
||||
|
||||
/**
|
||||
* This is the desktop view wrapper of the System View viewer.
|
||||
|
@ -71,6 +78,8 @@ public class TerminalViewTab extends Composite {
|
|||
|
||||
private final CTabFolder tabFolder;
|
||||
|
||||
private IPropertyChangeListener propertyChangeListener;
|
||||
|
||||
private Menu menu;
|
||||
|
||||
private boolean fMenuAboutToShow;
|
||||
|
@ -123,6 +132,11 @@ public class TerminalViewTab extends Composite {
|
|||
}
|
||||
|
||||
public void dispose() {
|
||||
if (propertyChangeListener != null) {
|
||||
IThemeManager mgr = PlatformUI.getWorkbench().getThemeManager();
|
||||
mgr.removePropertyChangeListener(propertyChangeListener);
|
||||
propertyChangeListener = null;
|
||||
}
|
||||
if (!tabFolder.isDisposed()) {
|
||||
tabFolder.dispose();
|
||||
}
|
||||
|
@ -183,6 +197,47 @@ public class TerminalViewTab extends Composite {
|
|||
}
|
||||
}
|
||||
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
// for now always update
|
||||
if (tabFolder!=null) {
|
||||
CTabItem[] items = tabFolder.getItems();
|
||||
for (int i=0; i<items.length; i++) {
|
||||
Object control = items[i].getData(DATA_KEY_CONTROL);
|
||||
if (control instanceof ITerminalViewControl) {
|
||||
updateTheme((ITerminalViewControl) control);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTheme(final ITerminalViewControl control) {
|
||||
if (control != null) {
|
||||
IThemeManager mgr = PlatformUI.getWorkbench().getThemeManager();
|
||||
Font font;
|
||||
FontRegistry fr = mgr.getCurrentTheme().getFontRegistry();
|
||||
if (fr.hasValueFor("terminal.views.view.font.definition")) { //$NON-NLS-1$
|
||||
//Terminal View font if available
|
||||
font = fr.get("terminal.views.view.font.definition"); //$NON-NLS-1$
|
||||
} else if (fr.hasValueFor("REMOTE_COMMANDS_VIEW_FONT")) { //$NON-NLS-1$
|
||||
//fallback: "Remote Shell Font"
|
||||
font = fr.get("REMOTE_COMMANDS_VIEW_FONT"); //$NON-NLS-1$
|
||||
} else {
|
||||
//fallback: "Basic Text Font"
|
||||
font = fr.get("org.eclipse.jface.textfont"); //$NON-NLS-1$
|
||||
}
|
||||
control.setFont(font);
|
||||
if (propertyChangeListener == null) {
|
||||
final TerminalViewTab myself = this;
|
||||
propertyChangeListener = new IPropertyChangeListener() {
|
||||
public void propertyChange(PropertyChangeEvent event) {
|
||||
myself.propertyChange(event);
|
||||
}
|
||||
};
|
||||
mgr.addPropertyChangeListener(propertyChangeListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CTabItem createTabItem(IAdaptable root,
|
||||
final String initialWorkingDirCmd) {
|
||||
final CTabItem item = new CTabItem(tabFolder, SWT.CLOSE);
|
||||
|
@ -250,6 +305,7 @@ public class TerminalViewTab extends Composite {
|
|||
}
|
||||
terminalControl.setConnector(connector);
|
||||
item.setData(DATA_KEY_CONTROL, terminalControl);
|
||||
updateTheme(terminalControl);
|
||||
terminalControl.connectTerminal();
|
||||
}
|
||||
item.setControl(c);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2009 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
|
||||
|
@ -10,6 +10,7 @@
|
|||
* Michael Scharf (Wind River) - [205260] Terminal does not take the font from the preferences
|
||||
* Michael Scharf (Wind River) - [209746] There are cases where some colors not displayed correctly
|
||||
* Michael Scharf (Wind River) - [206328] Terminal does not draw correctly with proportional fonts
|
||||
* Martin Oberhuber (Wind River) - [247700] Terminal uses ugly fonts in JEE package
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.textcanvas;
|
||||
|
||||
|
@ -41,7 +42,8 @@ public class StyleMap {
|
|||
|
||||
private static final String PREFIX = "org.eclipse.tm.internal."; //$NON-NLS-1$
|
||||
// TODO propagate the name of the font in the FontRegistry
|
||||
String fFontName="terminal.views.view.font.definition"; //$NON-NLS-1$
|
||||
private static final String fDefaultFontName="terminal.views.view.font.definition"; //$NON-NLS-1$
|
||||
String fFontName=fDefaultFontName;
|
||||
Map fColorMapForeground=new HashMap();
|
||||
Map fColorMapBackground=new HashMap();
|
||||
Map fFontMap=new HashMap();
|
||||
|
@ -169,6 +171,15 @@ public class StyleMap {
|
|||
public void updateFont() {
|
||||
Display display=Display.getCurrent();
|
||||
GC gc = new GC (display);
|
||||
if (JFaceResources.getFontRegistry().hasValueFor(fDefaultFontName)) {
|
||||
fFontName = fDefaultFontName;
|
||||
} else if (JFaceResources.getFontRegistry().hasValueFor("REMOTE_COMMANDS_VIEW_FONT")) { //$NON-NLS-1$
|
||||
//try RSE Shell View Font
|
||||
fFontName = "REMOTE_COMMANDS_VIEW_FONT"; //$NON-NLS-1$
|
||||
} else {
|
||||
//fall back to "basic jface text font"
|
||||
fFontName = "org.eclipse.jface.textfont"; //$NON-NLS-1$
|
||||
}
|
||||
gc.setFont(getFont());
|
||||
fCharSize = gc.textExtent ("W"); //$NON-NLS-1$
|
||||
fProportional=false;
|
||||
|
@ -184,11 +195,19 @@ public class StyleMap {
|
|||
measureChar(gc, c,false);
|
||||
}
|
||||
if(fProportional) {
|
||||
fCharSize.x-=3;
|
||||
fCharSize.x-=2; //works better on small fonts
|
||||
}
|
||||
for (int i = 0; i < fOffsets.length; i++) {
|
||||
fOffsets[i]=(fCharSize.x-fOffsets[i])/2;
|
||||
}
|
||||
if(!fProportional) {
|
||||
//measure font in boldface, too, and if wider then treat like proportional
|
||||
gc.setFont(getFont(fDefaultStyle.setBold(true)));
|
||||
Point charSizeBold = gc.textExtent("W"); //$NON-NLS-1$
|
||||
if (fCharSize.x != charSizeBold.x) {
|
||||
fProportional=true;
|
||||
}
|
||||
}
|
||||
gc.dispose ();
|
||||
}
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue