/* * (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) { DecoratedField dField = new DecoratedField( subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP, new TextControlCreator()); Text text = (Text) dField.getControl(); FormData d = (FormData) text.getLayoutData(); d.height = text.getLineHeight(); text.getParent().setSize(subComposite.getSize().x, text.getLineHeight()); Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT); rowSizeByLine = text.getLineHeight(); dField.getLayoutControl().dispose(); rowSizeFixed = ITabbedPropertyConstants.VSPACE + (initialSize.y - rowSizeByLine); estimateInitialized = true; } return rowSizeFixed + (rowSizeByLine * param.getNbLines()); }
/* * (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()); } 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; }