use of org.talend.commons.ui.swt.colorstyledtext.ColorStyledText in project tdi-studio-se by Talend.
the class MessageMemoController method refresh.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#refresh(org
* .talend.core.model.process.IElementParameter, boolean)
*/
@Override
public void refresh(IElementParameter param, boolean check) {
ColorStyledText labelText = (ColorStyledText) hashCurControls.get(param.getName());
if (labelText == null || labelText.isDisposed()) {
return;
}
Object value = param.getValue();
boolean valueChanged = false;
if (value == null) {
//$NON-NLS-1$
labelText.setText("");
} else {
if (!value.equals(labelText.getText())) {
labelText.setText((String) value);
valueChanged = true;
}
}
if (check || valueChanged) {
checkErrorsForPropertiesOnly(labelText);
}
fixedCursorPosition(param, labelText, value, valueChanged);
}
use of org.talend.commons.ui.swt.colorstyledtext.ColorStyledText in project tdi-studio-se by Talend.
the class AbstractLanguageMemoController method estimateRowSize.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize
* (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
*/
@Override
public int estimateRowSize(Composite subComposite, IElementParameter param) {
if (!estimateInitialized) {
IControlCreator txtCtrl = new IControlCreator() {
@Override
public Control createControl(final Composite parent, final int style) {
final ColorStyledText colorText = new ColorStyledText(parent, style, CorePlugin.getDefault().getPreferenceStore(), language);
Display display = Display.getCurrent();
if (display == null) {
display = Display.getDefault();
}
if (display != null) {
display.syncExec(new Runnable() {
@Override
public void run() {
IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
FontData fontData = new FontData(fontType);
Font font = new Font(parent.getDisplay(), fontData);
addResourceDisposeListener(colorText, font);
colorText.setFont(font);
}
});
}
return colorText;
}
};
DecoratedField dField = null;
if (param.getNbLines() != 1) {
dField = new DecoratedField(subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP, txtCtrl);
} else {
dField = new DecoratedField(subComposite, SWT.BORDER | SWT.WRAP, txtCtrl);
}
StyledText text = (StyledText) dField.getControl();
FormData d = (FormData) text.getLayoutData();
d.height = text.getLineHeight();
text.getParent().setSize(subComposite.getSize().x, text.getLineHeight());
rowSizeByLine = text.getLineHeight();
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
dField.getLayoutControl().dispose();
rowSizeFixed = ITabbedPropertyConstants.VSPACE + (initialSize.y - rowSizeByLine);
estimateInitialized = true;
}
return rowSizeFixed + (rowSizeByLine * param.getNbLines());
}
use of org.talend.commons.ui.swt.colorstyledtext.ColorStyledText in project tdi-studio-se by Talend.
the class SqlMemoController method estimateRowSize.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize
* (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
*/
@Override
public int estimateRowSize(Composite subComposite, IElementParameter param) {
IControlCreator txtCtrl = new IControlCreator() {
@Override
public Control createControl(final Composite parent, final int style) {
return createColorStyledText(parent, style);
}
};
DecoratedField dField = null;
if (param.getNbLines() != 1) {
dField = new DecoratedField(subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, txtCtrl);
} else {
dField = new DecoratedField(subComposite, SWT.BORDER, txtCtrl);
}
ColorStyledText text = (ColorStyledText) dField.getControl();
FormData d = (FormData) text.getLayoutData();
d.height = text.getLineHeight() * param.getNbLines();
text.getParent().setSize(subComposite.getSize().x, text.getLineHeight() * param.getNbLines());
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
dField.getLayoutControl().dispose();
return initialSize.y + ITabbedPropertyConstants.VSPACE;
}
use of org.talend.commons.ui.swt.colorstyledtext.ColorStyledText in project tdi-studio-se by Talend.
the class ErDiagramComposite method addErDiagramEditor.
/**
* admin Comment method "addErDiagramEditor".
*/
//$NON-NLS-1$
@SuppressWarnings("unchecked")
private void addErDiagramEditor(boolean isShowDesignerPage) {
GridData gridData = new GridData(GridData.FILL_BOTH);
this.setLayoutData(gridData);
GridLayout layout = new GridLayout();
layout.verticalSpacing = 0;
layout.marginLeft = 0;
layout.marginRight = 0;
layout.marginBottom = 0;
layout.marginTop = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 1;
this.setLayout(layout);
editor = new ErdiagramDiagramEditor();
editor.createPartControl(this);
editor.getViewer().setContents(createErDiagram(isShowDesignerPage));
Control control = editor.getGraphicalControl();
if (control != null) {
control.setParent(this);
control.setLayoutData(gridData);
}
layout = new GridLayout();
layout.marginLeft = 0;
layout.marginRight = 0;
layout.marginBottom = 0;
layout.marginTop = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.heightHint = 30;
int textstyle = SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL;
sqlText = new ColorStyledText(this, textstyle, CorePlugin.getDefault().getPreferenceStore(), language);
sqlText.setLayoutData(gridData);
//$NON-NLS-1$
sqlText.setText("");
sqlText.setBackground(getBackground());
sqlText.addModifyListener(new ModifyListener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
*/
public void modifyText(ModifyEvent e) {
sqlString = sqlText.getText();
}
});
}
use of org.talend.commons.ui.swt.colorstyledtext.ColorStyledText in project tdi-studio-se by Talend.
the class MessageMemoController method createColorStyledText.
private ColorStyledText createColorStyledText(final Composite parent, final int style) {
IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
//$NON-NLS-1$
ColorStyledText colorText = new ColorStyledText(parent, style, preferenceStore, "tsql");
String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
FontData fontData = new FontData(fontType);
Font font = new Font(parent.getDisplay(), fontData);
// Font font = new Font(null, "courier", 8, SWT.NONE); //$NON-NLS-1$
addResourceDisposeListener(colorText, font);
colorText.setFont(font);
return colorText;
}
Aggregations