use of org.eclipse.swt.graphics.FontData in project tdi-studio-se by Talend.
the class SqlMemoController method createColorStyledText.
private ColorStyledText createColorStyledText(final Composite parent, final int style) {
//$NON-NLS-1$
ColorStyledText colorText = new ColorStyledText(parent, style, CorePlugin.getDefault().getPreferenceStore(), "tsql");
IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
FontData fontData = new FontData(fontType);
Font font = new Font(null, fontData);
addResourceDisposeListener(colorText, font);
colorText.setFont(font);
return colorText;
}
use of org.eclipse.swt.graphics.FontData in project tdi-studio-se by Talend.
the class AbstractLabelProvider method getmonospacedFont.
/**
* Gets the monospaced font.
*
* @param baseFont The base font
* @return The monospaced font
*/
protected Font getmonospacedFont(Font baseFont) {
if (monospacedFont == null) {
FontData[] fontData = baseFont.getFontData();
for (String name : monospacedFonts) {
if (!fontData[0].getName().equals(name)) {
fontData[0].setName(name);
break;
}
}
monospacedFont = new Font(Display.getDefault(), fontData);
return monospacedFont;
}
return monospacedFont;
}
use of org.eclipse.swt.graphics.FontData in project tdi-studio-se by Talend.
the class SqlEditDialog method createDialogArea.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite control = (Composite) super.createDialogArea(parent);
// create text viewer
GridData gid = new GridData();
gid.grabExcessHorizontalSpace = true;
gid.grabExcessVerticalSpace = true;
gid.horizontalAlignment = GridData.FILL;
gid.verticalAlignment = GridData.FILL;
control.setLayoutData(gid);
GridLayout gridLayout = new GridLayout();
gridLayout.marginBottom = 0;
gridLayout.marginHeight = 0;
gridLayout.marginLeft = 0;
gridLayout.marginRight = 0;
gridLayout.marginTop = 0;
gridLayout.marginWidth = 0;
control.setLayout(gridLayout);
colorText = new ColorStyledText(control, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, CorePlugin.getDefault().getPreferenceStore(), language);
IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
FontData fontData = new FontData(fontType);
Font font = new Font(null, fontData);
addResourceDisposeListener(colorText, font);
colorText.setFont(font);
GridData gd = new GridData(GridData.FILL_BOTH);
colorText.setLayoutData(gd);
colorText.setText(sql);
colorText.addModifyListener(new ModifyListener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
*/
@Override
public void modifyText(ModifyEvent e) {
sql = colorText.getText();
}
});
createEditorProposal();
return control;
}
use of org.eclipse.swt.graphics.FontData in project tdi-studio-se by Talend.
the class SQLBuilderEditorComposite method createEditorArea.
/**
* Creates UI for editor.
*
* @param parent
*/
private void createEditorArea(Composite parent) {
// create divider line
Composite div1 = new Composite(parent, SWT.NONE);
GridData lgid = new GridData();
lgid.grabExcessHorizontalSpace = true;
lgid.horizontalAlignment = GridData.FILL;
lgid.heightHint = 1;
lgid.verticalIndent = 1;
div1.setLayoutData(lgid);
div1.setBackground(parent.getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
// create text viewer
GridData gid = new GridData();
gid.grabExcessHorizontalSpace = true;
gid.grabExcessVerticalSpace = true;
gid.horizontalAlignment = GridData.FILL;
gid.verticalAlignment = GridData.FILL;
colorText = new ColorStyledText(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, CorePlugin.getDefault().getPreferenceStore(), language);
IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
FontData fontData = new FontData(fontType);
Font font = new Font(null, fontData);
addResourceDisposeListener(colorText, font);
colorText.setFont(font);
GridData gd = new GridData(GridData.FILL_BOTH);
colorText.setLayoutData(gd);
colorText.setText(this.connParam.getQuery());
colorText.addVerifyKeyListener(new VerifyKeyListener() {
@Override
public void verifyKey(VerifyEvent event) {
if (event.stateMask == SWT.CTRL && event.keyCode == 13) {
event.doit = false;
execSQLAction.run();
}
}
});
colorText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
isModified = true;
}
});
}
use of org.eclipse.swt.graphics.FontData in project tdi-studio-se by Talend.
the class MemoController method createControl.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
*/
@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow, final int nbInRow, final int top, final Control lastControl) {
this.curParameter = param;
this.paramFieldType = param.getFieldType();
int nbLines = param.getNbLines();
DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP, new SelectAllTextControlCreator());
if (param.isRequired()) {
FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
}
Control cLayout = dField.getLayoutControl();
Text text = (Text) dField.getControl();
editionControlHelper.register(param.getName(), text);
FormData d = (FormData) text.getLayoutData();
if (getAdditionalHeightSize() != 0) {
nbLines += this.getAdditionalHeightSize() / text.getLineHeight();
}
d.height = text.getLineHeight() * nbLines;
FormData data;
text.getParent().setSize(subComposite.getSize().x, text.getLineHeight() * nbLines);
cLayout.setBackground(subComposite.getBackground());
// for bug 7580
if (!(text instanceof Text)) {
text.setEnabled(!param.isReadOnly());
} else {
text.setEditable(!param.isReadOnly() && !param.isRepositoryValueUsed());
}
IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
FontData fontData = new FontData(fontType);
Font font = new Font(null, fontData);
addResourceDisposeListener(text, font);
text.setFont(font);
if (elem instanceof Node) {
text.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
addDragAndDropTarget(text);
CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
data = new FormData();
if (lastControl != null) {
data.left = new FormAttachment(lastControl, 0);
} else {
data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
}
data.top = new FormAttachment(0, top);
labelLabel.setLayoutData(data);
if (numInRow != 1) {
labelLabel.setAlignment(SWT.RIGHT);
}
// *********************
data = new FormData();
int currentLabelWidth = STANDARD_LABEL_WIDTH;
GC gc = new GC(labelLabel);
Point labelSize = gc.stringExtent(param.getDisplayName());
gc.dispose();
if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
}
if (numInRow == 1) {
if (lastControl != null) {
data.left = new FormAttachment(lastControl, currentLabelWidth);
} else {
data.left = new FormAttachment(0, currentLabelWidth);
}
} else {
data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
}
data.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
data.top = new FormAttachment(0, top);
cLayout.setLayoutData(data);
// **********************
hashCurControls.put(param.getName(), text);
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
return null;
}
Aggregations