use of org.eclipse.swt.graphics.FontData in project MonjaDB by Kanatoko.
the class SWTResourceManager method getFont.
/**
* Returns a {@link Font} based on its name, height and style. Windows-specific strikeout and underline
* flags are also supported.
*
* @param name
* the name of the font
* @param size
* the size of the font
* @param style
* the style of the font
* @param strikeout
* the strikeout flag (warning: Windows only)
* @param underline
* the underline flag (warning: Windows only)
* @return {@link Font} The font matching the name, height, style, strikeout and underline
*/
public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) {
String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline;
Font font = m_fontMap.get(fontName);
if (font == null) {
FontData fontData = new FontData(name, size, style);
if (strikeout || underline) {
try {
//$NON-NLS-1$
Class<?> logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT");
//$NON-NLS-1$
Object logFont = FontData.class.getField("data").get(fontData);
if (logFont != null && logFontClass != null) {
if (strikeout) {
//$NON-NLS-1$
logFontClass.getField("lfStrikeOut").set(logFont, Byte.valueOf((byte) 1));
}
if (underline) {
//$NON-NLS-1$
logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte) 1));
}
}
} catch (Throwable e) {
//$NON-NLS-1$ //$NON-NLS-2$
System.err.println("Unable to set underline or strikeout" + " (probably on a non-Windows platform). " + e);
}
}
font = new Font(Display.getCurrent(), fontData);
m_fontMap.put(fontName, font);
}
return font;
}
use of org.eclipse.swt.graphics.FontData in project MonjaDB by Kanatoko.
the class SWTResourceManager method getBoldFont.
/**
* Returns a bold version of the given {@link Font}.
*
* @param baseFont
* the {@link Font} for which a bold version is desired
* @return the bold version of the given {@link Font}
*/
public static Font getBoldFont(Font baseFont) {
Font font = m_fontToBoldFontMap.get(baseFont);
if (font == null) {
FontData[] fontDatas = baseFont.getFontData();
FontData data = fontDatas[0];
font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD);
m_fontToBoldFontMap.put(baseFont, font);
}
return font;
}
use of org.eclipse.swt.graphics.FontData in project azure-tools-for-java by Microsoft.
the class WebAppDeployDialog method createDialogArea.
/**
* Create contents of the dialog.
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent) {
setMessage("Select App Service to deploy to:");
setTitle("Deploy Web App");
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayout(new GridLayout(2, false));
GridData gd_container = new GridData(GridData.FILL_BOTH);
gd_container.widthHint = 750;
container.setLayoutData(gd_container);
table = new Table(container, SWT.BORDER | SWT.FULL_SELECTION);
GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
gd_table.heightHint = 300;
table.setLayoutData(gd_table);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn tblclmnName = new TableColumn(table, SWT.LEFT);
tblclmnName.setWidth(230);
tblclmnName.setText("Name");
TableColumn tblclmnJdk = new TableColumn(table, SWT.LEFT);
tblclmnJdk.setWidth(60);
tblclmnJdk.setText("JDK");
TableColumn tblclmnWebContainer = new TableColumn(table, SWT.LEFT);
tblclmnWebContainer.setWidth(110);
tblclmnWebContainer.setText("Web container");
TableColumn tblclmnResourceGroup = new TableColumn(table, SWT.LEFT);
tblclmnResourceGroup.setWidth(190);
tblclmnResourceGroup.setText("Resource group");
Composite composite = new Composite(container, SWT.NONE);
composite.setLayout(new RowLayout(SWT.VERTICAL));
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
Button btnCreate = new Button(composite, SWT.NONE);
btnCreate.setLayoutData(new RowData(90, SWT.DEFAULT));
btnCreate.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sendTelemetry("CREATE");
createAppService();
//cleanError();
}
});
btnCreate.setText("Create...");
btnDelete = new Button(composite, SWT.NONE);
btnDelete.setEnabled(false);
btnDelete.setLayoutData(new RowData(90, SWT.DEFAULT));
btnDelete.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sendTelemetry("DELETE");
deleteAppService();
//cleanError();
}
});
btnDelete.setText("Delete...");
Button btnRefresh = new Button(composite, SWT.NONE);
btnRefresh.setLayoutData(new RowData(90, SWT.DEFAULT));
btnRefresh.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sendTelemetry("REFRESH");
//cleanError();
table.removeAll();
//browserAppServiceDetailes.setText("");
fillAppServiceDetails();
AzureModel.getInstance().setResourceGroupToWebAppMap(null);
fillTable();
}
});
btnRefresh.setText("Refresh");
Group grpAppServiceDetails = new Group(container, SWT.NONE);
grpAppServiceDetails.setLayout(new FillLayout(SWT.HORIZONTAL));
GridData gd_grpAppServiceDetails = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
gd_grpAppServiceDetails.heightHint = 150;
grpAppServiceDetails.setLayoutData(gd_grpAppServiceDetails);
grpAppServiceDetails.setText("App service details");
browserAppServiceDetailes = new Browser(grpAppServiceDetails, SWT.NONE);
FontData browserFontData = btnRefresh.getFont().getFontData()[0];
//browserFontStyle = String.format("font-family: '%s';", browserFontData.getHeight(), browserFontData.getName());
browserFontStyle = String.format("font-family: '%s'; font-size: 9pt;", browserFontData.getName());
browserAppServiceDetailes.addLocationListener(new LocationListener() {
public void changing(LocationEvent event) {
try {
//System.out.println("LocationEvent.location: " + event.location);
if (event.location.contains(ftpLinkString)) {
event.doit = false;
showFtpCreadentialsWindow();
}
if (event.location.contains("http")) {
event.doit = false;
PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL(event.location));
}
} catch (Exception ex) {
ex.printStackTrace();
LOG.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "changing@LocationListener@browserAppServiceDetailes@AppServiceCreateDialog", ex));
}
}
public void changed(LocationEvent event) {
}
});
new Label(container, SWT.NONE);
btnDeployToRoot = new Button(container, SWT.CHECK);
btnDeployToRoot.setText("Deploy to root");
new Label(container, SWT.NONE);
table.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
fillAppServiceDetails();
}
});
return area;
}
use of org.eclipse.swt.graphics.FontData in project tdi-studio-se by Talend.
the class DebugProcessTosComposite method setConsoleFont.
private boolean setConsoleFont() {
IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
String fontType = preferenceStore.getString(RunProcessPrefsConstants.CONSOLE_FONT);
if (StringUtils.isNotEmpty(fontType)) {
FontData fontData = new FontData(fontType);
if (consoleText.getFont() != null) {
FontData oldFont = consoleText.getFont().getFontData()[0];
// font is same
if (oldFont.equals(fontData)) {
return false;
}
}
Font font = new Font(this.getDisplay(), fontData);
consoleText.setFont(font);
return true;
}
return false;
}
use of org.eclipse.swt.graphics.FontData in project tdi-studio-se by Talend.
the class ProcessComposite method setConsoleFont.
/**
* DOC chuang Comment method "setConsoleFont".
*/
private void setConsoleFont() {
IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
FontData fontData = PreferenceConverter.getFontData(preferenceStore, TalendDesignerPrefConstants.CONSOLT_TEXT_FONT);
if (fontData != null) {
if (consoleText.getFont() != null) {
FontData oldFont = consoleText.getFont().getFontData()[0];
// font is same
if (!oldFont.equals(fontData)) {
Font font = new Font(this.getDisplay(), fontData);
consoleText.setFont(font);
}
// else no need to change the font it is the same
} else {
Font font = new Font(this.getDisplay(), fontData);
consoleText.setFont(font);
}
} else {
// should never happend
//$NON-NLS-1$
log.info("Could not find default font for the console");
}
}
Aggregations